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

Change-Id: I47fe8cb5d8a3c9876cd4c313dca1a8cc531288ec
diff --git a/java/java-impl/java-impl.iml b/java/java-impl/java-impl.iml
index b305503..b7b5d03 100644
--- a/java/java-impl/java-impl.iml
+++ b/java/java-impl/java-impl.iml
@@ -33,6 +33,7 @@
     <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="" />
+    <orderEntry type="module" module-name="external-system-api" />
   </component>
   <component name="copyright">
     <Base>
diff --git a/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java b/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java
index 50f48cb..0cb53dd 100644
--- a/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java
@@ -30,7 +30,6 @@
 import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
-import com.intellij.psi.impl.source.PsiDiamondTypeElementImpl;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.search.searches.ClassInheritorsSearch;
 import com.intellij.psi.tree.IElementType;
@@ -81,7 +80,7 @@
   }
 
   public static <T extends PsiElement> T findElementInRange(PsiFile file, int startOffset, int endOffset, Class<T> klass) {
-    return CodeInsightUtilBase.findElementInRange(file, startOffset, endOffset, klass, StdLanguages.JAVA);
+    return CodeInsightUtilCore.findElementInRange(file, startOffset, endOffset, klass, StdLanguages.JAVA);
   }
 
   @NotNull
@@ -203,7 +202,7 @@
     PsiElement[] children = scope.getChildren();
     for (PsiElement child : children) {
       if (child instanceof PsiExpression) {
-        if (areExpressionsEquivalent(RefactoringUtil.unparenthesizeExpression((PsiExpression)child), expr)) {
+        if (JavaPsiEquivalenceUtil.areExpressionsEquivalent(RefactoringUtil.unparenthesizeExpression((PsiExpression)child), expr)) {
           array.add((PsiExpression)child);
           continue;
         }
@@ -233,30 +232,6 @@
     }
   }
 
-  public static boolean areExpressionsEquivalent(PsiExpression expr1, PsiExpression expr2) {
-    return PsiEquivalenceUtil.areElementsEquivalent(expr1, expr2, new Comparator<PsiElement>() {
-      @Override
-      public int compare(PsiElement o1, PsiElement o2) {
-        if (o1 instanceof PsiParameter && o2 instanceof PsiParameter && ((PsiParameter)o1).getDeclarationScope() instanceof PsiMethod) {
-          return ((PsiParameter)o1).getName().compareTo(((PsiParameter)o2).getName());
-        }
-        return 1;
-      }
-    }, new Comparator<PsiElement>() {
-        @Override
-        public int compare(PsiElement o1, PsiElement o2) {
-          if (!o1.textMatches(o2)) return 1;
-
-          if (o1 instanceof PsiDiamondTypeElementImpl && o2 instanceof PsiDiamondTypeElementImpl) {
-            final PsiDiamondType.DiamondInferenceResult thisInferenceResult = new PsiDiamondTypeImpl(o1.getManager(), (PsiTypeElement)o1).resolveInferredTypes();
-            final PsiDiamondType.DiamondInferenceResult otherInferenceResult = new PsiDiamondTypeImpl(o2.getManager(), (PsiTypeElement)o2).resolveInferredTypes();
-            return thisInferenceResult.equals(otherInferenceResult) ? 0 : 1;
-          }
-          return 0;
-        }
-      }, null, false);
-  }
-
   public static Editor positionCursor(final Project project, PsiFile targetFile, PsiElement element) {
     TextRange range = element.getTextRange();
     int textOffset = range.getStartOffset();
diff --git a/java/java-impl/src/com/intellij/codeInsight/ConditionCheckManager.java b/java/java-impl/src/com/intellij/codeInsight/ConditionCheckManager.java
deleted file mode 100644
index f7edb1e..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/ConditionCheckManager.java
+++ /dev/null
@@ -1,182 +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.codeInsight;
-
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiMethod;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:johnnyclark@gmail.com">Johnny Clark</a>
- *         Creation Date: 8/3/12
- */
-@State(
-  name = "ConditionCheckManager",
-  storages = {
-    @Storage(id = "dir", file = StoragePathMacros.PROJECT_CONFIG_DIR + "/checker.xml", scheme = StorageScheme.DIRECTORY_BASED),
-    @Storage(file = StoragePathMacros.PROJECT_FILE)
-  }
-)
-public class ConditionCheckManager implements PersistentStateComponent<ConditionCheckManager.State> {
-  @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) private State state;
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.ConditionCheckManager");
-
-  private List<ConditionChecker> myIsNullCheckMethods = new ArrayList<ConditionChecker>();
-  private List<ConditionChecker> myIsNotNullCheckMethods = new ArrayList<ConditionChecker>();
-
-  private List<ConditionChecker> myAssertIsNullMethods = new ArrayList<ConditionChecker>();
-  private List<ConditionChecker> myAssertIsNotNullMethods = new ArrayList<ConditionChecker>();
-
-  private List<ConditionChecker> myAssertTrueMethods = new ArrayList<ConditionChecker>();
-  private List<ConditionChecker> myAssertFalseMethods = new ArrayList<ConditionChecker>();
-
-  public static ConditionCheckManager getInstance(Project project) {
-    return ServiceManager.getService(project, ConditionCheckManager.class);
-  }
-
-  public void setIsNullCheckMethods(List<ConditionChecker> methodConditionChecks) {
-    myIsNullCheckMethods.clear();
-    myIsNullCheckMethods.addAll(methodConditionChecks);
-  }
-
-  public void setIsNotNullCheckMethods(List<ConditionChecker> methodConditionChecks) {
-    myIsNotNullCheckMethods.clear();
-    myIsNotNullCheckMethods.addAll(methodConditionChecks);
-  }
-
-  public void setAssertIsNullMethods(List<ConditionChecker> methodConditionChecks) {
-    myAssertIsNullMethods.clear();
-    myAssertIsNullMethods.addAll(methodConditionChecks);
-  }
-
-  public void setAssertIsNotNullMethods(List<ConditionChecker> methodConditionChecks) {
-    myAssertIsNotNullMethods.clear();
-    myAssertIsNotNullMethods.addAll(methodConditionChecks);
-  }
-
-  public void setAssertTrueMethods(List<ConditionChecker> psiMethodWrappers) {
-    myAssertTrueMethods.clear();
-    myAssertTrueMethods.addAll(psiMethodWrappers);
-  }
-
-  public void setAssertFalseMethods(List<ConditionChecker> psiMethodWrappers) {
-    myAssertFalseMethods.clear();
-    myAssertFalseMethods.addAll(psiMethodWrappers);
-  }
-
-  public List<ConditionChecker> getIsNullCheckMethods() {
-    return myIsNullCheckMethods;
-  }
-
-  public List<ConditionChecker> getIsNotNullCheckMethods() {
-    return myIsNotNullCheckMethods;
-  }
-
-  public List<ConditionChecker> getAssertIsNullMethods() {
-    return myAssertIsNullMethods;
-  }
-
-  public List<ConditionChecker> getAssertIsNotNullMethods() {
-    return myAssertIsNotNullMethods;
-  }
-
-  public List<ConditionChecker> getAssertFalseMethods() {
-    return myAssertFalseMethods;
-  }
-
-  public List<ConditionChecker> getAssertTrueMethods() {
-    return myAssertTrueMethods;
-  }
-
-  public static class State {
-    public List<String> myIsNullCheckMethods = new ArrayList<String>();
-    public List<String> myIsNotNullCheckMethods = new ArrayList<String>();
-    public List<String> myAssertIsNullMethods = new ArrayList<String>();
-    public List<String> myAssertIsNotNullMethods = new ArrayList<String>();
-    public List<String> myAssertTrueMethods = new ArrayList<String>();
-    public List<String> myAssertFalseMethods = new ArrayList<String>();
-  }
-
-  @Override
-  public State getState() {
-    State state = new State();
-
-    loadMethodChecksToState(state.myIsNullCheckMethods, myIsNullCheckMethods);
-    loadMethodChecksToState(state.myIsNotNullCheckMethods, myIsNotNullCheckMethods);
-    loadMethodChecksToState(state.myAssertIsNullMethods, myAssertIsNullMethods);
-    loadMethodChecksToState(state.myAssertIsNotNullMethods, myAssertIsNotNullMethods);
-    loadMethodChecksToState(state.myAssertTrueMethods, myAssertTrueMethods);
-    loadMethodChecksToState(state.myAssertFalseMethods, myAssertFalseMethods);
-
-    return state;
-  }
-
-  private static void loadMethodChecksToState(List<String> listToLoadTo, List<ConditionChecker> listToLoadFrom) {
-    for (ConditionChecker checker : listToLoadFrom) {
-      listToLoadTo.add(checker.toString());
-    }
-  }
-
-  @Override
-  public void loadState(State state) {
-    this.state = state;
-    loadMethods(myIsNullCheckMethods, state.myIsNullCheckMethods, ConditionChecker.Type.IS_NULL_METHOD);
-    loadMethods(myIsNotNullCheckMethods, state.myIsNotNullCheckMethods, ConditionChecker.Type.IS_NOT_NULL_METHOD);
-    loadMethods(myAssertIsNullMethods, state.myAssertIsNullMethods, ConditionChecker.Type.ASSERT_IS_NULL_METHOD);
-    loadMethods(myAssertIsNotNullMethods, state.myAssertIsNotNullMethods, ConditionChecker.Type.ASSERT_IS_NOT_NULL_METHOD);
-    loadMethods(myAssertTrueMethods, state.myAssertTrueMethods, ConditionChecker.Type.ASSERT_TRUE_METHOD);
-    loadMethods(myAssertFalseMethods, state.myAssertFalseMethods, ConditionChecker.Type.ASSERT_FALSE_METHOD);
-  }
-
-  private static void loadMethods(List<ConditionChecker> listToLoadTo, List<String> listToLoadFrom, ConditionChecker.Type type){
-    listToLoadTo.clear();
-    for (String setting : listToLoadFrom) {
-      try {
-        listToLoadTo.add(new ConditionChecker.FromConfigBuilder(setting, type).build());
-      } catch (Exception e) {
-        LOG.error("Problem occurred while attempting to load Condition Check from configuration file. " + e.getMessage());
-      }
-    }
-  }
-
-  @Nullable
-  public static ConditionChecker findConditionChecker(@NotNull PsiMethod method) {
-    ConditionCheckManager instance = getInstance(method.getProject());
-    ConditionChecker checker = methodMatches(method, instance.getIsNullCheckMethods());
-    if (checker == null) checker = methodMatches(method, instance.getIsNotNullCheckMethods());
-    if (checker == null) checker = methodMatches(method, instance.getAssertIsNullMethods());
-    if (checker == null) checker = methodMatches(method, instance.getAssertIsNotNullMethods());
-    if (checker == null) checker = methodMatches(method, instance.getAssertTrueMethods());
-    if (checker == null) checker = methodMatches(method, instance.getAssertFalseMethods());
-    return checker;
-  }
-
-  private static ConditionChecker methodMatches(PsiMethod psiMethod, List<ConditionChecker> checkers) {
-    for (ConditionChecker checker : checkers) {
-      if (checker.matchesPsiMethod(psiMethod)) {
-        return checker;
-      }
-    }
-    return null;
-  }
-
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/ConditionChecker.java b/java/java-impl/src/com/intellij/codeInsight/ConditionChecker.java
deleted file mode 100644
index de3871d..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/ConditionChecker.java
+++ /dev/null
@@ -1,431 +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.codeInsight;
-
-import com.intellij.openapi.diagnostic.*;
-import com.intellij.psi.*;
-import org.jetbrains.annotations.*;
-
-import java.io.*;
-import java.util.*;
-
-
-/**
- * Used by Constant Condition Inspection to identify methods which perform some type of Validation on the parameters passed into them.
- * For example given the following method
- * <pre>
- * {@code
- *  class Foo {
- *     static boolean validateNotNull(Object o) {
- *       if (o == null) return false;
- *       else return true;
- *     }
- *   }
- * }
- *
- * The corresponding ConditionCheck would be <p/>
- * myConditionCheckType=Type.IS_NOT_NULL_METHOD
- * myClassName=Foo
- * myMethodName=validateNotNull
- * myPsiParameter=o
- *
- * The following block of code would produce a Inspection Warning that o is always true
- *
- *  <pre>
- * {@code
- *   if (Value.isNotNull(o)) {
- *     if(o != null) {}
- *   }
- * }
- * </pre>
- *
- * @author <a href="mailto:johnnyclark@gmail.com">Johnny Clark</a>
- *         Creation Date: 8/14/12
- */
-public class ConditionChecker implements Serializable {
-  private final @NotNull Type myConditionCheckType;
-
-  public enum Type {
-    IS_NULL_METHOD("IsNull Method"),
-    IS_NOT_NULL_METHOD("IsNotNull Method"),
-    ASSERT_IS_NULL_METHOD("Assert IsNull Method"),
-    ASSERT_IS_NOT_NULL_METHOD("Assert IsNotNull Method"),
-    ASSERT_TRUE_METHOD("Assert True Method"),
-    ASSERT_FALSE_METHOD("Assert False Method");
-    private final String myStringRepresentation;
-
-    Type(String stringRepresentation) {
-      myStringRepresentation = stringRepresentation;
-    }
-
-    @Override
-    public String toString() {
-      return myStringRepresentation;
-    }
-  }
-
-  private final @NotNull String myClassName;
-  private final @NotNull String myMethodName;
-  private final @NotNull List<String> myParameterClassList;
-  private final int myCheckedParameterIndex;
-  private final String myFullName;
-
-  private ConditionChecker(@NotNull String className,
-                           @NotNull String methodName,
-                           @NotNull List<String> parameterClassList,
-                           int checkedParameterIndex,
-                           @NotNull Type type,
-                           @NotNull String fullName) {
-    checkState(!className.isEmpty(), "Class Name is blank");
-    checkState(!methodName.isEmpty(), "Method Name is blank");
-    checkState(!parameterClassList.isEmpty(), "Parameter Class List is empty");
-    checkState(checkedParameterIndex >= 0, "CheckedParameterIndex must be greater than or equal to zero");
-    checkState(parameterClassList.size() >= checkedParameterIndex, "CheckedParameterIndex is greater than Parameter Class List's size");
-    checkState(!fullName.isEmpty(), "Method Name is blank");
-
-    myConditionCheckType = type;
-    myClassName = className;
-    myMethodName = methodName;
-    myParameterClassList = parameterClassList;
-    myCheckedParameterIndex = checkedParameterIndex;
-    myFullName = fullName;
-  }
-
-  private static void checkState(boolean condition, String errorMsg) {
-    if (!condition) throw new IllegalArgumentException(errorMsg);
-  }
-
-  public static String getFullyQualifiedName(PsiParameter psiParameter) {
-    PsiTypeElement typeElement = psiParameter.getTypeElement();
-    if (typeElement == null) throw new RuntimeException("Parameter has null typeElement " + psiParameter.getName());
-
-    PsiType psiType = typeElement.getType();
-
-    return psiType.getCanonicalText();
-  }
-
-  public boolean matchesPsiMethod(PsiMethod psiMethod) {
-    if (!myMethodName.equals(psiMethod.getName())) return false;
-
-    PsiClass containingClass = psiMethod.getContainingClass();
-    if (containingClass == null) return false;
-
-    String qualifiedName = containingClass.getQualifiedName();
-    if (qualifiedName == null) return false;
-
-    if (!myClassName.equals(qualifiedName)) return false;
-
-    PsiParameterList psiParameterList = psiMethod.getParameterList();
-    if (myParameterClassList.size() != psiParameterList.getParameters().length) return false;
-
-    for (int i = 0; i < psiParameterList.getParameters().length; i++) {
-      PsiParameter psiParameter = psiParameterList.getParameters()[i];
-      PsiTypeElement psiTypeElement = psiParameter.getTypeElement();
-      if (psiTypeElement == null) return false;
-
-      PsiType psiType = psiTypeElement.getType();
-      String parameterCanonicalText = psiType.getCanonicalText();
-      String myParameterCanonicalText = myParameterClassList.get(i);
-      if (!myParameterCanonicalText.equals(parameterCanonicalText)) return false;
-    }
-
-    return true;
-  }
-
-  public boolean matchesPsiMethod(PsiMethod psiMethod, int paramIndex) {
-    if (matchesPsiMethod(psiMethod) && paramIndex == myCheckedParameterIndex) return true;
-
-    return false;
-  }
-
-  public boolean overlaps(ConditionChecker otherChecker) {
-    if (myClassName.equals(otherChecker.myClassName) &&
-        myMethodName.equals(otherChecker.myMethodName) &&
-        myParameterClassList.equals(otherChecker.myParameterClassList) &&
-        myCheckedParameterIndex == otherChecker.myCheckedParameterIndex) {
-      return true;
-    }
-
-    return false;
-  }
-
-  @NotNull
-  public Type getConditionCheckType() {
-    return myConditionCheckType;
-  }
-
-  @NotNull
-  public String getClassName() {
-    return myClassName;
-  }
-
-  @NotNull
-  public String getMethodName() {
-    return myMethodName;
-  }
-
-  public int getCheckedParameterIndex() {
-    return myCheckedParameterIndex;
-  }
-
-  public String getFullName() {
-    return myFullName;
-  }
-
-  /**
-   * In addition to normal duties, this controls the manner in which the ConditionCheck appears in the ConditionCheckDialog.MethodsPanel
-   */
-  @Override
-  public String toString() {
-    return myFullName;
-  }
-
-  private static class Builder {
-
-    static String initFullName(String className,
-                               String methodName,
-                               List<String> parameterClasses,
-                               List<String> parameterNames,
-                               int checkedParameterIndex) {
-      String s = className + "." + methodName + "(";
-      int index = 0;
-      for (String parameterClass : parameterClasses) {
-        String parameterClassAndName = parameterClass + " " + parameterNames.get(index);
-        if (index == checkedParameterIndex) parameterClassAndName = "*" + parameterClassAndName + "*";
-
-        s += parameterClassAndName + ", ";
-        index++;
-      }
-      s = s.substring(0, s.length() - 2);
-      s += ")";
-      return s;
-    }
-  }
-
-  static class FromConfigBuilder extends Builder {
-    private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.ConditionCheck.FromConfigBuilder");
-    private final @NotNull String serializedRepresentation;
-    private final @NotNull Type type;
-
-    FromConfigBuilder(@NotNull String serializedRepresentation, @NotNull Type type) {
-      this.serializedRepresentation = serializedRepresentation;
-      this.type = type;
-    }
-
-    private String parseClassAndMethodName() {
-      if (!serializedRepresentation.contains("(")) {
-        throw new IllegalArgumentException("Name should contain a opening parenthesis.  " + serializedRepresentation);
-      }
-      else if (!serializedRepresentation.contains(")")) {
-        throw new IllegalArgumentException("Name should contain a closing parenthesis.  " + serializedRepresentation);
-      }
-      else if (serializedRepresentation.indexOf("(", serializedRepresentation.indexOf("(") + 1) > -1) {
-        throw new IllegalArgumentException("Name should only contain one opening parenthesis.  " + serializedRepresentation);
-      }
-      else if (serializedRepresentation.indexOf(")", serializedRepresentation.indexOf(")") + 1) > -1) {
-        throw new IllegalArgumentException("Name should only contain one closing parenthesis.  " + serializedRepresentation);
-      }
-      else if (serializedRepresentation.indexOf(")") < serializedRepresentation.indexOf("(")) {
-        throw new IllegalArgumentException("Opening parenthesis should precede closing parenthesis.  " + serializedRepresentation);
-      }
-
-      String classAndMethodName = serializedRepresentation.substring(0, serializedRepresentation.indexOf("("));
-      if (!classAndMethodName.contains(".")) {
-        throw new IllegalArgumentException(
-          "Name should contain a dot between the class name and method name (before the opening parenthesis).  " +
-          serializedRepresentation);
-      }
-      return classAndMethodName;
-    }
-
-    @Nullable
-    public ConditionChecker build() {
-      try {
-        String classAndMethodName = parseClassAndMethodName();
-
-        String className = classAndMethodName.substring(0, classAndMethodName.lastIndexOf("."));
-        String methodName = classAndMethodName.substring(classAndMethodName.lastIndexOf(".") + 1);
-
-        String allParametersSubString =
-          serializedRepresentation.substring(serializedRepresentation.indexOf("(") + 1, serializedRepresentation.lastIndexOf(")")).trim();
-        if (allParametersSubString.isEmpty()) {
-          throw new IllegalArgumentException(
-            "Name should contain 1+ parameter (between opening and closing parenthesis).  " + serializedRepresentation);
-        }
-        else if (allParametersSubString.contains("*") && allParametersSubString.indexOf("*") == allParametersSubString.lastIndexOf("*")) {
-          throw new IllegalArgumentException("Selected Parameter should be surrounded by asterisks.  " + serializedRepresentation);
-        }
-
-        List<String> parameterClasses = new ArrayList<String>();
-        List<String> parameterNames = new ArrayList<String>();
-        int checkParameterIndex = -1;
-        int index = 0;
-        for (String parameterClassAndName : allParametersSubString.split(",")) {
-          parameterClassAndName = parameterClassAndName.trim();
-          if (parameterClassAndName.startsWith("*") && parameterClassAndName.endsWith("*")) {
-            checkParameterIndex = index;
-            parameterClassAndName = parameterClassAndName.substring(1, parameterClassAndName.length() - 1);
-          }
-
-          String[] parameterClassAndNameSplit = parameterClassAndName.split(" ");
-          String parameterClass = parameterClassAndNameSplit[0];
-          String parameterName = parameterClassAndNameSplit[1];
-          parameterClasses.add(parameterClass);
-          parameterNames.add(parameterName);
-          index++;
-        }
-        String fullName = initFullName(className, methodName, parameterClasses, parameterNames, checkParameterIndex);
-        return new ConditionChecker(className, methodName, parameterClasses, checkParameterIndex, type, fullName);
-      }
-      catch (Exception e) {
-        LOG.error("An Exception occurred while attempting to build ConditionCheck for Serialized String '" +
-                  serializedRepresentation +
-                  "' and Type '" +
-                  type +
-                  "'", e);
-        return null;
-      }
-    }
-  }
-
-  public static class FromPsiBuilder extends Builder {
-    private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.ConditionCheck.FromPsiBuilder");
-    private final @NotNull PsiMethod psiMethod;
-    private final @NotNull PsiParameter psiParameter;
-    private final @NotNull Type type;
-
-    public FromPsiBuilder(@NotNull PsiMethod psiMethod, @NotNull PsiParameter psiParameter, @NotNull Type type) {
-      this.psiMethod = psiMethod;
-      this.psiParameter = psiParameter;
-      this.type = type;
-    }
-
-    private static void validatePsiMethodHasContainingClass(PsiMethod psiMethod) {
-      PsiElement psiElement = psiMethod.getContainingClass();
-      if (!(psiElement instanceof PsiClass)) {
-        throw new IllegalArgumentException("PsiMethod " + psiMethod + " can not have a null containing class.");
-      }
-    }
-
-    private static void validatePsiMethodReturnTypeForNonAsserts(PsiMethod psiMethod, Type type) {
-      PsiType returnType = psiMethod.getReturnType();
-      if (isAssert(type)) return;
-
-      if (returnType == null) throw new IllegalArgumentException("PsiMethod " + psiMethod + " has a null return type PsiType.");
-
-      if (returnType != PsiType.BOOLEAN && !returnType.getCanonicalText().equals(Boolean.class.toString())) {
-        throw new IllegalArgumentException("PsiMethod " + psiMethod + " must have a null return type PsiType of boolean or Boolean.");
-      }
-    }
-
-    private static void validatePsiParameterExistsInPsiMethod(PsiMethod psiMethod, PsiParameter psiParameter) {
-      boolean parameterFound = false;
-      PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
-      for (PsiParameter parameter : parameters) {
-        if (psiParameter.equals(parameter)) {
-          parameterFound = true;
-          break;
-        }
-      }
-
-      if (!parameterFound) {
-        throw new IllegalArgumentException("PsiMethod " + psiMethod + " must have parameter " + getFullyQualifiedName(psiParameter));
-      }
-    }
-
-    private static boolean isAssert(Type type) {
-      return type == Type.ASSERT_IS_NULL_METHOD ||
-             type == Type.ASSERT_IS_NOT_NULL_METHOD ||
-             type == Type.ASSERT_TRUE_METHOD ||
-             type == Type.ASSERT_FALSE_METHOD;
-    }
-
-    private static String initClassNameFromPsiMethod(PsiMethod psiMethod) {
-      PsiElement psiElement = psiMethod.getContainingClass();
-      PsiClass psiClass = (PsiClass)psiElement;
-      if (psiClass == null) throw new IllegalStateException("PsiClass is null");
-
-      String qualifiedName = psiClass.getQualifiedName();
-      if (qualifiedName == null || qualifiedName.isEmpty()) throw new IllegalStateException("Qualified Name is Blank");
-      return qualifiedName;
-    }
-
-    private static String initMethodNameFromPsiMethod(PsiMethod psiMethod) {
-      return psiMethod.getName();
-    }
-
-    private static List<String> initParameterClassListFromPsiMethod(PsiMethod psiMethod) {
-      List<String> parameterClasses = new ArrayList<String>();
-      PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
-      for (PsiParameter param : parameters) {
-        PsiTypeElement typeElement = param.getTypeElement();
-        if (typeElement == null) throw new RuntimeException("Parameter has null typeElement " + param.getName());
-
-        PsiType psiType = typeElement.getType();
-
-        parameterClasses.add(psiType.getCanonicalText());
-      }
-      return parameterClasses;
-    }
-
-    private static List<String> initParameterNameListFromPsiMethod(PsiMethod psiMethod) {
-      List<String> parameterNames = new ArrayList<String>();
-      PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
-      for (PsiParameter param : parameters) {
-        parameterNames.add(param.getName());
-      }
-      return parameterNames;
-    }
-
-    private static int initCheckedParameterIndex(PsiMethod psiMethod, PsiParameter psiParameterToFind) {
-      PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
-      for (int i = 0; i < parameters.length; i++) {
-        PsiParameter param = parameters[i];
-        if (param.equals(psiParameterToFind)) return i;
-      }
-      throw new IllegalStateException();
-    }
-
-    private void validateConstructorArgs(PsiMethod psiMethod, PsiParameter psiParameter) {
-      validatePsiMethodHasContainingClass(psiMethod);
-      validatePsiMethodReturnTypeForNonAsserts(psiMethod, type);
-      validatePsiParameterExistsInPsiMethod(psiMethod, psiParameter);
-    }
-
-    @Nullable
-    public ConditionChecker build() {
-      try {
-        validateConstructorArgs(psiMethod, psiParameter);
-
-        String className = initClassNameFromPsiMethod(psiMethod);
-        String methodName = initMethodNameFromPsiMethod(psiMethod);
-        List<String> parameterClassList = initParameterClassListFromPsiMethod(psiMethod);
-        List<String> parameterNameList = initParameterNameListFromPsiMethod(psiMethod);
-        int checkedParameterIndex = initCheckedParameterIndex(psiMethod, psiParameter);
-        String fullName = initFullName(className, methodName, parameterClassList, parameterNameList, checkedParameterIndex);
-        return new ConditionChecker(className, methodName, parameterClassList, checkedParameterIndex, type, fullName);
-      }
-      catch (Exception e) {
-        LOG.error("An Exception occurred while attempting to build ConditionCheck for PsiMethod '" + psiMethod +
-                  "' PsiParameter='" + psiParameter + "' " +
-                  "' and Type '" +
-                  type +
-                  "'", e);
-        return null;
-      }
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
index a4306bb..c4c156c 100644
--- a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
+++ b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
@@ -18,6 +18,7 @@
 import com.intellij.CommonBundle;
 import com.intellij.ProjectTopics;
 import com.intellij.codeInsight.highlighting.HighlightManager;
+import com.intellij.diagnostic.LogMessageEx;
 import com.intellij.icons.AllIcons;
 import com.intellij.ide.DataManager;
 import com.intellij.ide.highlighter.XmlFileType;
@@ -126,6 +127,7 @@
                                  @NotNull final String annotationFQName,
                                  @NotNull final PsiFile fromFile,
                                  @Nullable final PsiNameValuePair[] value) {
+    ApplicationManager.getApplication().assertIsDispatchThread();
     final Project project = myPsiManager.getProject();
     final PsiFile containingFile = listOwner.getContainingFile();
     if (!(containingFile instanceof PsiJavaFile)) {
@@ -336,6 +338,7 @@
 
   @Override
   public boolean deannotate(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN) {
+    ApplicationManager.getApplication().assertIsDispatchThread();
     return processExistingExternalAnnotations(listOwner, annotationFQN, new Processor<XmlTag>() {
       @Override
       public boolean process(XmlTag annotationTag) {
@@ -355,6 +358,7 @@
   public boolean editExternalAnnotation(@NotNull PsiModifierListOwner listOwner,
                                         @NotNull final String annotationFQN,
                                         @Nullable final PsiNameValuePair[] value) {
+    ApplicationManager.getApplication().assertIsDispatchThread();
     return processExistingExternalAnnotations(listOwner, annotationFQN, new Processor<XmlTag>() {
       @Override
       public boolean process(XmlTag annotationTag) {
@@ -365,7 +369,8 @@
     });
   }
 
-  private boolean processExistingExternalAnnotations(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN,
+  private boolean processExistingExternalAnnotations(@NotNull final PsiModifierListOwner listOwner,
+                                                     @NotNull final String annotationFQN,
                                                      @NotNull final Processor<XmlTag> annotationTagProcessor) {
     try {
       final List<XmlFile> files = findExternalAnnotationsXmlFiles(listOwner);
@@ -428,6 +433,7 @@
   @Override
   @NotNull
   public AnnotationPlace chooseAnnotationsPlace(@NotNull final PsiElement element) {
+    ApplicationManager.getApplication().assertIsDispatchThread();
     if (!element.isPhysical()) return AnnotationPlace.IN_CODE; //element just created
     if (!element.getManager().isInProject(element)) return AnnotationPlace.EXTERNAL;
     final Project project = myPsiManager.getProject();
@@ -634,6 +640,12 @@
     return null;
   }
 
+  @Override
+  protected void duplicateError(@NotNull PsiFile file, @NotNull String externalName, @NotNull String text) {
+    String message = text + "; for signature: '" + externalName + "' in the file " + file.getVirtualFile().getPresentableUrl();
+    LogMessageEx.error(LOG, message, file.getText());
+  }
+
   private static class MyExternalPromptDialog extends OptionsMessageDialog {
     private final Project myProject;
     private static final String ADD_IN_CODE = ProjectBundle.message("external.annotations.in.code.option");
diff --git a/java/java-impl/src/com/intellij/codeInsight/TestFrameworksImpl.java b/java/java-impl/src/com/intellij/codeInsight/TestFrameworksImpl.java
deleted file mode 100644
index 08c7cd2..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/TestFrameworksImpl.java
+++ /dev/null
@@ -1,79 +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.
- */
-
-/*
- * User: anna
- * Date: 28-May-2007
- */
-package com.intellij.codeInsight;
-
-import com.intellij.openapi.extensions.Extensions;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiMethod;
-import com.intellij.testIntegration.TestFramework;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.Nullable;
-
-public class TestFrameworksImpl extends TestFrameworks {
-  private TestFrameworksImpl() {
-  }
-
-  @Override
-  public boolean isTestClass(final PsiClass psiClass) {
-    final TestFramework[] testFrameworks = Extensions.getExtensions(TestFramework.EXTENSION_NAME);
-    for (TestFramework framework : testFrameworks) {
-      if (framework.isTestClass(psiClass)) {
-        return true;
-      }
-    }
-    return false;
-  }
-
-  @Override
-  @Nullable
-  public PsiMethod findOrCreateSetUpMethod(final PsiClass psiClass) {
-    final TestFramework[] testFrameworks = Extensions.getExtensions(TestFramework.EXTENSION_NAME);
-    for (TestFramework framework : testFrameworks) {
-      if (framework.isTestClass(psiClass)) {
-        try {
-          final PsiMethod setUpMethod = (PsiMethod)framework.findOrCreateSetUpMethod(psiClass);
-          if (setUpMethod != null) {
-            return setUpMethod;
-          }
-        }
-        catch (IncorrectOperationException e) {
-          //skip
-        }
-      }
-    }
-    return null;
-  }
-
-  @Override
-  @Nullable
-  public PsiMethod findSetUpMethod(final PsiClass psiClass) {
-    final TestFramework[] testFrameworks = Extensions.getExtensions(TestFramework.EXTENSION_NAME);
-    for (TestFramework framework : testFrameworks) {
-      if (framework.isTestClass(psiClass)) {
-        final PsiMethod setUpMethod = (PsiMethod)framework.findSetUpMethod(psiClass);
-        if (setUpMethod != null) {
-          return setUpMethod;
-        }
-      }
-    }
-    return null;
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java b/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java
index 6343a29..ac8297d 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.completion;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
@@ -89,7 +89,7 @@
             context.setTailOffset(psiReference.getRangeInElement().getEndOffset() + psiReference.getElement().getTextRange().getStartOffset());
             final PsiElement newUnderlying = psiReference.bindToElement(psiClass);
             if (newUnderlying != null) {
-              final PsiElement psiElement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(newUnderlying);
+              final PsiElement psiElement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(newUnderlying);
               if (psiElement != null) {
                 for (final PsiReference reference : psiElement.getReferences()) {
                   if (psiManager.areElementsEquivalent(psiClass, JavaCompletionUtil.resolveReference(reference))) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/ClassByNameMerger.java b/java/java-impl/src/com/intellij/codeInsight/completion/ClassByNameMerger.java
deleted file mode 100644
index 5496bb1..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/completion/ClassByNameMerger.java
+++ /dev/null
@@ -1,62 +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.completion;
-
-import com.intellij.codeInsight.CodeInsightSettings;
-import com.intellij.codeInsight.lookup.LookupElement;
-import com.intellij.codeInsight.lookup.LookupElementBuilder;
-import com.intellij.util.Consumer;
-
-/**
-* @author peter
-*/
-public class ClassByNameMerger implements Consumer<LookupElement> {
-  private int number = 0;
-  private LookupElement lastElement;
-  private final boolean myShouldMerge;
-  private final CompletionResultSet myResult;
-
-  public ClassByNameMerger(CompletionParameters parameters, CompletionResultSet result) {
-    myShouldMerge = parameters.getInvocationCount() == 0 && CodeInsightSettings.getInstance().SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS;
-    myResult = result;
-  }
-
-  @Override
-  public void consume(LookupElement element) {
-    if (!myShouldMerge) {
-      myResult.addElement(element);
-      return;
-    }
-
-    if (lastElement != null) {
-      if (lastElement.getLookupString().equals(element.getLookupString())) {
-        number++;
-        lastElement = LookupElementBuilder.create(element.getLookupString()).withTailText(" (" + number + " variants...)", true);
-        return;
-      }
-
-      myResult.addElement(lastElement);
-    }
-    lastElement = element;
-    number = 1;
-  }
-
-  public void finishedClassProcessing() {
-    if (lastElement != null) {
-      myResult.addElement(lastElement);
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java
index 4480f31..b98ad7a 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java
@@ -15,7 +15,6 @@
  */
 package com.intellij.codeInsight.completion;
 
-import com.intellij.codeInsight.CodeInsightSettings;
 import com.intellij.codeInsight.TailType;
 import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor;
 import com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFix;
@@ -415,13 +414,7 @@
   }
 
   public static boolean mayStartClassName(CompletionResultSet result) {
-    String prefix = result.getPrefixMatcher().getPrefix();
-    if (StringUtil.isEmpty(prefix)) {
-      return false;
-    }
-
-    return StringUtil.isCapitalized(prefix) ||
-           CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE == CodeInsightSettings.NONE;
+    return StringUtil.isNotEmpty(result.getPrefixMatcher().getPrefix());
   }
 
   private static void completeAnnotationAttributeName(CompletionResultSet result, PsiElement insertedElement,
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java
index e2050a4..163b2c6 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java
@@ -677,7 +677,7 @@
           documentManager.doPostponedOperationsAndUnblockDocument(document);
           documentManager.commitDocument(document);
 
-          newElement = CodeInsightUtilBase.findElementInRange(file, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(),
+          newElement = CodeInsightUtilCore.findElementInRange(file, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(),
                                                               PsiJavaCodeReferenceElement.class,
                                                               JavaLanguage.INSTANCE);
           rangeMarker.dispose();
@@ -764,12 +764,14 @@
       context.setAddCompletionChar(false);
     }
 
-    final boolean needRightParenth = forceClosingParenthesis || !smart && (CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET || hasTail);
     if (hasTail) {
       hasParams = false;
     }
+    final boolean needRightParenth = forceClosingParenthesis ||
+                                     !smart && (CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET ||
+                                                !hasParams && completionChar != '(');
 
-    PsiDocumentManager.getInstance(context.getProject()).commitDocument(context.getDocument());
+    context.commitDocument();
 
     final CommonCodeStyleSettings styleSettings = context.getCodeStyleSettings();
     final PsiElement elementAt = file.findElementAt(context.getStartOffset());
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java
index 6e95a4c..cbfde63 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java
@@ -16,9 +16,11 @@
 package com.intellij.codeInsight.completion;
 
 import com.intellij.codeInsight.ExpectedTypeInfo;
+import com.intellij.codeInsight.completion.impl.BetterPrefixMatcher;
 import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
 import com.intellij.codeInsight.lookup.AutoCompletionPolicy;
 import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.filters.ElementFilter;
@@ -39,9 +41,9 @@
 public class JavaNoVariantsDelegator extends CompletionContributor {
 
   @Override
-  public void fillCompletionVariants(final CompletionParameters parameters, final CompletionResultSet result) {
-    final boolean empty = containsOnlyPackages(result.runRemainingContributors(parameters, true)) ||
-                          suggestMetaAnnotations(parameters);
+  public void fillCompletionVariants(final CompletionParameters parameters, CompletionResultSet result) {
+    LinkedHashSet<CompletionResult> plainResults = result.runRemainingContributors(parameters, true);
+    final boolean empty = containsOnlyPackages(plainResults) || suggestMetaAnnotations(parameters);
 
     if (!empty && parameters.getInvocationCount() == 0) {
       result.restartCompletionWhenNothingMatches();
@@ -49,6 +51,15 @@
 
     if (empty) {
       delegate(parameters, JavaCompletionSorting.addJavaSorting(parameters, result));
+    } else if (Registry.is("ide.completion.show.all.classes") || Registry.is("ide.completion.show.better.matching.classes")) {
+      if (parameters.getInvocationCount() <= 1 &&
+          JavaCompletionContributor.mayStartClassName(result) &&
+          JavaCompletionContributor.isClassNamePossible(parameters)) {
+        if (Registry.is("ide.completion.show.better.matching.classes")) {
+          result = result.withPrefixMatcher(new BetterPrefixMatcher(result.getPrefixMatcher(), BetterPrefixMatcher.getBestMatchingDegree(plainResults))); 
+        }
+        suggestNonImportedClasses(parameters, result);
+      }
     }
   }
 
@@ -158,9 +169,8 @@
     return allClasses;
   }
 
-  private static void suggestNonImportedClasses(CompletionParameters parameters, CompletionResultSet result) {
-    final ClassByNameMerger merger = new ClassByNameMerger(parameters, result);
-
+  private static void suggestNonImportedClasses(CompletionParameters parameters, final CompletionResultSet _result) {
+    final CompletionResultSet result = JavaCompletionSorting.addJavaSorting(parameters, _result);
     JavaClassNameCompletionContributor.addAllClasses(parameters,
                                                      true, result.getPrefixMatcher(), new Consumer<LookupElement>() {
       @Override
@@ -170,10 +180,8 @@
           classElement.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
         }
 
-        merger.consume(classElement);
+        result.addElement(element);
       }
     });
-
-    merger.finishedClassProcessing();
   }
 }
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/RecursionWeigher.java b/java/java-impl/src/com/intellij/codeInsight/completion/RecursionWeigher.java
index 79a8b04..6d03085 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/RecursionWeigher.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/RecursionWeigher.java
@@ -15,8 +15,8 @@
  */
 package com.intellij.codeInsight.completion;
 
-import com.intellij.codeInsight.CodeInsightUtil;
 import com.intellij.codeInsight.ExpectedTypeInfo;
+import com.intellij.codeInsight.JavaPsiEquivalenceUtil;
 import com.intellij.codeInsight.lookup.LookupElement;
 import com.intellij.codeInsight.lookup.LookupElementWeigher;
 import com.intellij.openapi.util.Comparing;
@@ -79,7 +79,7 @@
     if (myCallQualifier != null &&
         myPositionQualifier != null &&
         myCallQualifier != myPositionQualifier &&
-        CodeInsightUtil.areExpressionsEquivalent(myCallQualifier, myPositionQualifier)) {
+        JavaPsiEquivalenceUtil.areExpressionsEquivalent(myCallQualifier, myPositionQualifier)) {
       return false;
     }
 
@@ -162,7 +162,7 @@
     return Result.normal;
   }
 
-  @Nullable 
+  @Nullable
   private String getSetterPropertyName(@Nullable PsiMethod calledMethod) {
     if (PropertyUtil.isSimplePropertySetter(calledMethod)) {
       assert calledMethod != null;
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java b/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java
index 5e44202..ae1ae20 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java
@@ -226,10 +226,10 @@
     if (myOptions.showInstanceInStaticContext && !isQualifiedContext()) {
       return true;
     }
-    if (!(element instanceof PsiClass) && element instanceof PsiModifierListOwner) {
+    if (element instanceof PsiModifierListOwner) {
       PsiModifierListOwner modifierListOwner = (PsiModifierListOwner)element;
       if (myStatic) {
-        if (!modifierListOwner.hasModifierProperty(PsiModifier.STATIC)) {
+        if (!(element instanceof PsiClass) && !modifierListOwner.hasModifierProperty(PsiModifier.STATIC)) {
           // we don't need non static method in static context.
           return false;
         }
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java
index 875d600..b647e7d 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java
@@ -31,7 +31,6 @@
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.DumbService;
-import com.intellij.openapi.project.IndexNotReadyException;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.text.StringUtil;
@@ -68,15 +67,10 @@
   @Nullable
   public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) {
     PsiElement parent;
-    if (element instanceof PsiIdentifier && (parent = element.getParent()) instanceof PsiMethod) {
+    if (element instanceof PsiIdentifier && (parent = element.getParent()) instanceof PsiMethod && 
+        !DumbService.getInstance(element.getProject()).isDumb()) {
       PsiMethod method = (PsiMethod)parent;
-      MethodSignatureBackedByPsiMethod superSignature = null;
-      try {
-        superSignature = SuperMethodsSearch.search(method, null, true, false).findFirst();
-      }
-      catch (IndexNotReadyException e) {
-        //some searchers (EJB) require indices. What shall we do?
-      }
+      MethodSignatureBackedByPsiMethod superSignature = SuperMethodsSearch.search(method, null, true, false).findFirst();
       if (superSignature != null) {
         boolean overrides =
           method.hasModifierProperty(PsiModifier.ABSTRACT) == superSignature.getMethod().hasModifierProperty(PsiModifier.ABSTRACT);
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java
index 1c21876..a36521f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java
@@ -22,10 +22,7 @@
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
 import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
 import com.intellij.codeInsight.daemon.JavaErrorMessages;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightMethodUtil;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.*;
 import com.intellij.codeInsight.daemon.impl.quickfix.*;
 import com.intellij.codeInsight.intention.EmptyIntentionAction;
 import com.intellij.codeInsight.intention.IntentionAction;
@@ -38,7 +35,7 @@
 import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection;
 import com.intellij.codeInspection.unusedParameters.UnusedParametersInspection;
 import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
-import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
+import com.intellij.codeInspection.util.SpecialAnnotationsUtilBase;
 import com.intellij.diagnostic.LogMessageEx;
 import com.intellij.diagnostic.errordialog.Attachment;
 import com.intellij.find.FindManager;
@@ -442,7 +439,7 @@
 
         QuickFixAction.registerQuickFixAction(info, new CreateGetterOrSetterFix(false, true, field), myUnusedSymbolKey);
         QuickFixAction.registerQuickFixAction(info, HighlightMethodUtil.getFixRange(field), new CreateConstructorParameterFromFieldFix(field));
-        SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes(field, new Processor<String>() {
+        SpecialAnnotationsUtilBase.createAddToSpecialAnnotationFixes(field, new Processor<String>() {
           @Override
           public boolean process(final String annoName) {
             QuickFixAction.registerQuickFixAction(info, UnusedSymbolLocalInspection.createQuickFix(annoName, "fields", field.getProject()));
@@ -497,7 +494,7 @@
            myUnusedSymbolInspection.REPORT_PARAMETER_FOR_PUBLIC_METHODS &&
            !isOverriddenOrOverrides(method)) &&
           !method.hasModifierProperty(PsiModifier.NATIVE) &&
-          !HighlightMethodUtil.isSerializationRelatedMethod(method, method.getContainingClass()) &&
+          !JavaHighlightUtil.isSerializationRelatedMethod(method, method.getContainingClass()) &&
           !PsiClassImplUtil.isMainOrPremainMethod(method)) {
         if (UnusedSymbolLocalInspection.isInjected(method)) return null;
         HighlightInfo highlightInfo = checkUnusedParameter(parameter, identifier, progress);
@@ -559,10 +556,11 @@
     String message = JavaErrorMessages.message(key, symbolName);
     final HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message, highlightInfoType);
     QuickFixAction.registerQuickFixAction(highlightInfo, new SafeDeleteFix(method), highlightDisplayKey);
-    SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes(method, new Processor<String>() {
+    SpecialAnnotationsUtilBase.createAddToSpecialAnnotationFixes(method, new Processor<String>() {
       @Override
       public boolean process(final String annoName) {
-        QuickFixAction.registerQuickFixAction(highlightInfo, UnusedSymbolLocalInspection.createQuickFix(annoName, "methods", method.getProject()));
+        QuickFixAction
+          .registerQuickFixAction(highlightInfo, UnusedSymbolLocalInspection.createQuickFix(annoName, "methods", method.getProject()));
         return true;
       }
     });
@@ -581,7 +579,7 @@
 
     boolean aPrivate = method.hasModifierProperty(PsiModifier.PRIVATE);
     PsiClass containingClass = method.getContainingClass();
-    if (HighlightMethodUtil.isSerializationRelatedMethod(method, containingClass)) return true;
+    if (JavaHighlightUtil.isSerializationRelatedMethod(method, containingClass)) return true;
     if (aPrivate) {
       if (isIntentionalPrivateConstructor(method, containingClass)) {
         return true;
@@ -727,10 +725,11 @@
     String message = JavaErrorMessages.message(pattern, symbolName);
     final HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message, highlightInfoType);
     QuickFixAction.registerQuickFixAction(highlightInfo, new SafeDeleteFix(aClass), highlightDisplayKey);
-    SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes((PsiModifierListOwner)aClass, new Processor<String>() {
+    SpecialAnnotationsUtilBase.createAddToSpecialAnnotationFixes((PsiModifierListOwner)aClass, new Processor<String>() {
       @Override
       public boolean process(final String annoName) {
-        QuickFixAction.registerQuickFixAction(highlightInfo, UnusedSymbolLocalInspection.createQuickFix(annoName, element, aClass.getProject()));
+        QuickFixAction
+          .registerQuickFixAction(highlightInfo, UnusedSymbolLocalInspection.createQuickFix(annoName, element, aClass.getProject()));
         return true;
       }
     });
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RecursiveCallLineMarkerProvider.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RecursiveCallLineMarkerProvider.java
index 8b66dce..0fd2685 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RecursiveCallLineMarkerProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RecursiveCallLineMarkerProvider.java
@@ -21,7 +21,7 @@
 import com.intellij.icons.AllIcons;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.editor.markup.GutterIconRenderer;
-import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -36,7 +36,7 @@
 /**
  * @author Danila Ponomarenko
  */
-public class RecursiveCallLineMarkerProvider implements LineMarkerProvider, DumbAware {
+public class RecursiveCallLineMarkerProvider implements LineMarkerProvider {
 
   @Override
   public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
@@ -49,6 +49,7 @@
     final Set<PsiStatement> statements = new HashSet<PsiStatement>();
 
     for (PsiElement element : elements) {
+      ProgressManager.checkCanceled();
       if (element instanceof PsiMethodCallExpression) {
         final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)element;
         final PsiStatement statement = PsiTreeUtil.getParentOfType(methodCall, PsiStatement.class, true, PsiMethod.class);
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java
index f0ac84d..6fd6ba5 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java
@@ -38,6 +38,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
 public class RefCountHolder {
@@ -56,19 +57,26 @@
   private static class HolderReference extends SoftReference<RefCountHolder> {
     @SuppressWarnings("UnusedDeclaration")
     private volatile RefCountHolder myHardRef; // to prevent gc
+    // number of live references to RefCountHolder. Once it reaches zero, hard ref is cleared
+    // the counter is used instead of a flag because multiple passes can be running simultaneously (one actual and several canceled winding down)
+    // and there is a chance they overlap the usage of RCH
+    private final AtomicInteger myRefCount = new AtomicInteger();
 
     public HolderReference(@NotNull RefCountHolder holder) {
       super(holder);
       myHardRef = holder;
     }
-    
-    private void makeHardReachable(boolean isHard) {
-      RefCountHolder holder = get();
-      assert !isHard || holder != null : "hard: "+isHard +"; holder="+holder;
-      myHardRef = isHard ? holder : null;
+
+    private void changeLivenessBy(int delta) {
+      if (myRefCount.addAndGet(delta) == 0) {
+        myHardRef = null;
+      }
+      else if (myHardRef == null) {
+        myHardRef = get();
+      }
     }
   }
-  
+
   private static final Key<HolderReference> REF_COUNT_HOLDER_IN_FILE_KEY = Key.create("REF_COUNT_HOLDER_IN_FILE_KEY");
   @NotNull
   private static Pair<RefCountHolder, HolderReference> getInstance(@NotNull PsiFile file, boolean create) {
@@ -98,7 +106,7 @@
   public static RefCountHolder startUsing(@NotNull PsiFile file) {
     Pair<RefCountHolder, HolderReference> pair = getInstance(file, true);
     HolderReference reference = pair.second;
-    reference.makeHardReachable(true); // make sure RefCountHolder won't be gced during highlighting
+    reference.changeLivenessBy(1); // make sure RefCountHolder won't be gced during highlighting
     log("startUsing: " + pair.first.myState+" for "+file);
     return pair.first;
   }
@@ -107,12 +115,12 @@
   public static RefCountHolder endUsing(@NotNull PsiFile file) {
     Pair<RefCountHolder, HolderReference> pair = getInstance(file, false);
     HolderReference reference = pair.second;
-    reference.makeHardReachable(false); // no longer needed, can be cleared
+    reference.changeLivenessBy(-1); // no longer needed, can be cleared
     RefCountHolder holder = pair.first;
     log("endUsing: " + (holder == null ? null : holder.myState)+" for "+file);
     return holder;
   }
-  
+
   private RefCountHolder(@NotNull PsiFile file) {
     myFile = file;
     log("c: created: " + myState.get()+" for "+file);
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java
index 8346db9..6849d74 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java
@@ -133,12 +133,12 @@
       }
 
       String description = JavaErrorMessages.message("annotation.incompatible.types",
-                                                     formatReference(nameRef), HighlightUtil.formatType(expectedType));
+                                                     formatReference(nameRef), JavaHighlightUtil.formatType(expectedType));
       return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
     }
     if (value instanceof PsiArrayInitializerMemberValue) {
       if (expectedType instanceof PsiArrayType) return null;
-      String description = JavaErrorMessages.message("annotation.illegal.array.initializer", HighlightUtil.formatType(expectedType));
+      String description = JavaErrorMessages.message("annotation.illegal.array.initializer", JavaHighlightUtil.formatType(expectedType));
       return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
     }
     if (value instanceof PsiExpression) {
@@ -151,7 +151,7 @@
       }
 
       String description = JavaErrorMessages.message("annotation.incompatible.types",
-                                                     HighlightUtil.formatType(type), HighlightUtil.formatType(expectedType));
+                                                     JavaHighlightUtil.formatType(type), JavaHighlightUtil.formatType(expectedType));
       return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
     }
 
@@ -483,7 +483,7 @@
           final String qualifiedName = containingClass.getQualifiedName();
           if (CommonClassNames.JAVA_LANG_OBJECT.equals(qualifiedName) || CommonClassNames.JAVA_LANG_ANNOTATION_ANNOTATION.equals(qualifiedName)) {
             return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(nameIdentifier).descriptionAndTooltip(
-              "@interface member clashes with '" + HighlightUtil.formatMethod(method) + "' in " + HighlightUtil.formatClass(containingClass)).create();
+              "@interface member clashes with '" + JavaHighlightUtil.formatMethod(method) + "' in " + HighlightUtil.formatClass(containingClass)).create();
           }
         }
       }
@@ -599,7 +599,8 @@
     if (methods.length == 1) {
       PsiType expected = new PsiImmediateClassType((PsiClass)target, PsiSubstitutor.EMPTY).createArrayType();
       if (!expected.equals(methods[0].getReturnType())) {
-        return JavaErrorMessages.message("annotation.container.bad.type", container.getQualifiedName(), HighlightUtil.formatType(expected));
+        return JavaErrorMessages.message("annotation.container.bad.type", container.getQualifiedName(), JavaHighlightUtil
+          .formatType(expected));
       }
     }
 
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 000a035..5ee1703 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
@@ -15,7 +15,6 @@
  */
 package com.intellij.codeInsight.daemon.impl.analysis;
 
-import com.intellij.codeInsight.AnnotationUtil;
 import com.intellij.codeInsight.daemon.JavaErrorMessages;
 import com.intellij.codeInsight.daemon.impl.HighlightInfo;
 import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
@@ -41,7 +40,6 @@
 import com.intellij.util.containers.HashSet;
 import gnu.trove.THashMap;
 import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.*;
@@ -96,8 +94,8 @@
           String description = JavaErrorMessages.message(
             messageKey,
             HighlightUtil.formatClass(typeParameter),
-            HighlightUtil.formatType(extendsType),
-            HighlightUtil.formatType(substituted)
+            JavaHighlightUtil.formatType(extendsType),
+            JavaHighlightUtil.formatType(substituted)
           );
 
           return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(call).descriptionAndTooltip(description).create();
@@ -273,7 +271,7 @@
 
         String description = JavaErrorMessages.message(messageKey,
                                                        referenceClass != null ? HighlightUtil.formatClass(referenceClass) : type.getPresentableText(),
-                                                       HighlightUtil.formatType(bound));
+                                                       JavaHighlightUtil.formatType(bound));
 
         final HighlightInfo highlightInfo =
           HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement2Highlight).descriptionAndTooltip(description).create();
@@ -363,7 +361,7 @@
       return HighlightUtil.formatClass((PsiClass)typeParameterListOwner);
     }
     else if (typeParameterListOwner instanceof PsiMethod) {
-      return HighlightUtil.formatMethod((PsiMethod)typeParameterListOwner);
+      return JavaHighlightUtil.formatMethod((PsiMethod)typeParameterListOwner);
     }
     else {
       LOG.error("Unknown " + typeParameterListOwner);
@@ -447,8 +445,8 @@
           if (!Comparing.equal(type1, type2)) {
             String description = JavaErrorMessages.message("generics.cannot.be.inherited.with.different.type.arguments",
                                                            HighlightUtil.formatClass(superClass),
-                                                           HighlightUtil.formatType(type1),
-                                                           HighlightUtil.formatType(type2));
+                                                           JavaHighlightUtil.formatType(type1),
+                                                           JavaHighlightUtil.formatType(type2));
             return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create();
           }
         }
@@ -499,7 +497,7 @@
               .isInheritorOrSelf(containingClass, superContainingClass, true)) {
               if (superMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
                 final String inheritUnrelatedDefaultsMessage = HighlightUtil.formatClass(aClass) + " inherits unrelated defaults for " +
-                                                               HighlightUtil.formatMethod(method) + " from types " + HighlightUtil.formatClass(containingClass) +
+                                                               JavaHighlightUtil.formatMethod(method) + " from types " + HighlightUtil.formatClass(containingClass) +
                                                                " and " + HighlightUtil.formatClass(superContainingClass);
                 return HighlightInfo
                   .newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(inheritUnrelatedDefaultsMessage).create();
@@ -508,7 +506,7 @@
                 final String message = JavaErrorMessages.message(
                   aClass instanceof PsiEnumConstantInitializer ? "enum.constant.should.implement.method" : "class.must.be.abstract",
                   HighlightUtil.formatClass(superContainingClass),
-                  HighlightUtil.formatMethod(superMethod),
+                  JavaHighlightUtil.formatMethod(superMethod),
                   HighlightUtil.formatClass(superContainingClass, false));
                 return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(message).create();
               }
@@ -532,9 +530,9 @@
     MethodSignatureBackedByPsiMethod sameErasure = sameErasureMethods.get(signatureToErase);
     HighlightInfo info;
     if (sameErasure != null) {
-      if (aClass instanceof PsiTypeParameter || 
+      if (aClass instanceof PsiTypeParameter ||
           MethodSignatureUtil.findMethodBySuperMethod(aClass, sameErasure.getMethod(), false) != null ||
-          !(InheritanceUtil.isInheritorOrSelf(sameErasure.getMethod().getContainingClass(), method.getContainingClass(), true) || 
+          !(InheritanceUtil.isInheritorOrSelf(sameErasure.getMethod().getContainingClass(), method.getContainingClass(), true) ||
             InheritanceUtil.isInheritorOrSelf(method.getContainingClass(), sameErasure.getMethod().getContainingClass(), true))) {
         info = checkSameErasureNotSubSignatureOrSameClass(sameErasure, signature, aClass, method);
         if (info != null) return info;
@@ -659,7 +657,7 @@
         if (refParent instanceof PsiNewExpression) {
           PsiNewExpression newExpression = (PsiNewExpression)refParent;
           if (!(newExpression.getType() instanceof PsiArrayType)) {
-            String description = JavaErrorMessages.message("wildcard.type.cannot.be.instantiated", HighlightUtil.formatType(type));
+            String description = JavaErrorMessages.message("wildcard.type.cannot.be.instantiated", JavaHighlightUtil.formatType(type));
             return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create();
           }
         }
@@ -700,7 +698,7 @@
       if (toConvert instanceof PsiPrimitiveType) {
         final PsiClassType boxedType = ((PsiPrimitiveType)toConvert).getBoxedType(typeElement);
         if (boxedType != null) {
-          QuickFixAction.registerQuickFixAction(highlightInfo, 
+          QuickFixAction.registerQuickFixAction(highlightInfo,
                                                 new ReplacePrimitiveWithBoxedTypeAction(typeElement, toConvert.getPresentableText(), ((PsiPrimitiveType)toConvert).getBoxedTypeName()));
         }
       }
@@ -710,132 +708,15 @@
     return null;
   }
 
-  public static boolean isRawToGeneric(PsiType lType, PsiType rType) {
-    if (lType instanceof PsiPrimitiveType || rType instanceof PsiPrimitiveType) return false;
-    if (lType.equals(rType)) return false;
-    if (lType instanceof PsiArrayType && rType instanceof PsiArrayType) {
-      return isRawToGeneric(((PsiArrayType)lType).getComponentType(), ((PsiArrayType)rType).getComponentType());
-    }
-    if (lType instanceof PsiArrayType || rType instanceof PsiArrayType) return false;
-
-    if (rType instanceof PsiIntersectionType) {
-      for (PsiType type : ((PsiIntersectionType)rType).getConjuncts()) {
-        if (isRawToGeneric(lType, type)) return true;
-      }
-      return false;
-    }
-    if (lType instanceof PsiIntersectionType) {
-      for (PsiType type : ((PsiIntersectionType)lType).getConjuncts()) {
-        if (isRawToGeneric(type, rType)) return true;
-      }
-      return false;
-    }
-
-    if (!(lType instanceof PsiClassType) || !(rType instanceof PsiClassType)) return false;
-
-    PsiClassType.ClassResolveResult lResolveResult = ((PsiClassType)lType).resolveGenerics();
-    PsiClassType.ClassResolveResult rResolveResult = ((PsiClassType)rType).resolveGenerics();
-    PsiClass lClass = lResolveResult.getElement();
-    PsiClass rClass = rResolveResult.getElement();
-
-    if (rClass instanceof PsiAnonymousClass) {
-      return isRawToGeneric(lType, ((PsiAnonymousClass)rClass).getBaseClassType());
-    }
-
-    PsiSubstitutor lSubstitutor = lResolveResult.getSubstitutor();
-    PsiSubstitutor rSubstitutor = rResolveResult.getSubstitutor();
-    if (lClass == null || rClass == null) return false;
-    if (lClass instanceof PsiTypeParameter &&
-        !InheritanceUtil.isInheritorOrSelf(rClass, lClass, true)) {
-      return true;
-    }
-
-    if (!lClass.getManager().areElementsEquivalent(lClass, rClass)) {
-      if (lClass.isInheritor(rClass, true)) {
-        lSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(rClass, lClass, lSubstitutor);
-        lClass = rClass;
-      }
-      else if (rClass.isInheritor(lClass, true)) {
-        rSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(lClass, rClass, rSubstitutor);
-        rClass = lClass;
-      }
-      else {
-        return false;
-      }
-    }
-
-    Iterator<PsiTypeParameter> lIterator = PsiUtil.typeParametersIterator(lClass);
-    Iterator<PsiTypeParameter> rIterator = PsiUtil.typeParametersIterator(rClass);
-    while (lIterator.hasNext()) {
-      if (!rIterator.hasNext()) return false;
-      PsiTypeParameter lParameter = lIterator.next();
-      PsiTypeParameter rParameter = rIterator.next();
-      PsiType lTypeArg = lSubstitutor.substitute(lParameter);
-      PsiType rTypeArg = rSubstitutor.substituteWithBoundsPromotion(rParameter);
-      if (lTypeArg == null) continue;
-      if (rTypeArg == null) {
-        if (lTypeArg instanceof PsiWildcardType && ((PsiWildcardType)lTypeArg).getBound() == null) {
-          continue;
-        }
-        else {
-          return true;
-        }
-      }
-      if (!TypeConversionUtil.typesAgree(lTypeArg, rTypeArg, true)) return true;
-    }
-    return false;
-  }
-
-  public static boolean isUncheckedCast(PsiType castType, PsiType operandType) {
-    if (TypeConversionUtil.isAssignable(castType, operandType, false)) return false;
-
-    castType = castType.getDeepComponentType();
-    if (castType instanceof PsiClassType) {
-      final PsiClassType castClassType = (PsiClassType)castType;
-      operandType = operandType.getDeepComponentType();
-
-      if (!(operandType instanceof PsiClassType)) return false;
-      final PsiClassType operandClassType = (PsiClassType)operandType;
-      final PsiClassType.ClassResolveResult castResult = castClassType.resolveGenerics();
-      final PsiClassType.ClassResolveResult operandResult = operandClassType.resolveGenerics();
-      final PsiClass operandClass = operandResult.getElement();
-      final PsiClass castClass = castResult.getElement();
-
-      if (operandClass == null || castClass == null) return false;
-      if (castClass instanceof PsiTypeParameter) return true;
-
-      if (castClassType.hasNonTrivialParameters()) {
-        if (operandClassType.isRaw()) return true;
-        if (castClass.isInheritor(operandClass, true)) {
-          PsiSubstitutor castSubstitutor = castResult.getSubstitutor();
-          PsiElementFactory factory = JavaPsiFacade.getInstance(castClass.getProject()).getElementFactory();
-          for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(castClass)) {
-            PsiSubstitutor modifiedSubstitutor = castSubstitutor.put(typeParameter, null);
-            PsiClassType otherType = factory.createType(castClass, modifiedSubstitutor);
-            if (TypeConversionUtil.isAssignable(operandType, otherType, false)) return true;
-          }
-          for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(operandClass)) {
-            final PsiType operand = operandResult.getSubstitutor().substitute(typeParameter);
-            if (operand instanceof PsiCapturedWildcardType) return true;
-          }
-          return false;
-        }
-        return true;
-      }
-    }
-
-    return false;
-  }
-
   @Nullable
   public static HighlightInfo checkForeachLoopParameterType(PsiForeachStatement statement) {
     final PsiParameter parameter = statement.getIterationParameter();
     final PsiExpression expression = statement.getIteratedValue();
     if (expression == null || expression.getType() == null) return null;
-    final PsiType itemType = getCollectionItemType(expression);
+    final PsiType itemType = JavaGenericsUtil.getCollectionItemType(expression);
     if (itemType == null) {
       String description = JavaErrorMessages.message("foreach.not.applicable",
-                                                     HighlightUtil.formatType(expression.getType()));
+                                                     JavaHighlightUtil.formatType(expression.getType()));
       return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create();
     }
     final int start = parameter.getTextRange().getStartOffset();
@@ -848,61 +729,6 @@
     return highlightInfo;
   }
 
-  @Nullable
-  public static PsiType getCollectionItemType(@NotNull PsiExpression expression) {
-    final PsiType type = expression.getType();
-    if (type == null) return null;
-    return getCollectionItemType(type, expression.getResolveScope());
-  }
-
-  @Nullable
-  public static PsiType getCollectionItemType(final PsiType type, final GlobalSearchScope scope) {
-    if (type instanceof PsiArrayType) {
-      return ((PsiArrayType)type).getComponentType();
-    }
-    if (type instanceof PsiClassType) {
-      final PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)type).resolveGenerics();
-      PsiClass aClass = resolveResult.getElement();
-      if (aClass == null) return null;
-      final PsiManager manager = aClass.getManager();
-      final String qName = aClass.getQualifiedName();
-      PsiSubstitutor substitutor = resolveResult.getSubstitutor();
-      JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
-      if (qName != null) {
-        PsiClass myClass = facade.findClass(qName, scope);
-        if (myClass != null && myClass != aClass) {
-          //different JDKs
-          PsiTypeParameter thisTypeParameter = getIterableTypeParameter(facade, myClass);
-          if (thisTypeParameter == null) return null;
-          PsiTypeParameter thatTypeParameter = getIterableTypeParameter(facade, aClass);
-          if (thatTypeParameter != null) { //it can be null if we reference collection in JDK1.4 module from JDK5 source
-            substitutor = substitutor.put(thisTypeParameter, substitutor.substitute(thatTypeParameter));
-          }
-          aClass = myClass;
-        }
-      }
-      PsiTypeParameter typeParameter = getIterableTypeParameter(facade, aClass);
-      if (typeParameter == null) return null;
-      PsiClass owner = (PsiClass)typeParameter.getOwner();
-      if (owner == null) return null;
-      PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getClassSubstitutor(owner, aClass, PsiSubstitutor.EMPTY);
-      if (superClassSubstitutor == null) return null;
-      PsiType itemType = superClassSubstitutor.substitute(typeParameter);
-      itemType = substitutor.substitute(itemType);
-      return itemType == null ? PsiType.getJavaLangObject(manager, aClass.getResolveScope()) : itemType;
-    }
-    return null;
-  }
-
-  @Nullable
-  private static PsiTypeParameter getIterableTypeParameter(final JavaPsiFacade facade, final PsiClass context) {
-    PsiClass iterable = facade.findClass("java.lang.Iterable", context.getResolveScope());
-    if (iterable == null) return null;
-    PsiTypeParameter[] typeParameters = iterable.getTypeParameters();
-    if (typeParameters.length != 1) return null;
-    return typeParameters[0];
-  }
-
   //http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.9.2
   @Nullable
   public static HighlightInfo checkAccessStaticFieldFromEnumConstructor(PsiReferenceExpression expr, JavaResolveResult result) {
@@ -952,7 +778,7 @@
   @Nullable
   public static HighlightInfo checkGenericArrayCreation(PsiElement element, PsiType type) {
     if (type instanceof PsiArrayType) {
-      if (!isReifiableType(((PsiArrayType)type).getComponentType())) {
+      if (!JavaGenericsUtil.isReifiableType(((PsiArrayType)type).getComponentType())) {
         String description = JavaErrorMessages.message("generic.array.creation");
         return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create();
       }
@@ -1058,10 +884,10 @@
 
     if (resolved instanceof PsiClass) {
       final PsiClass containingClass = ((PsiClass)resolved).getContainingClass();
-      if (containingClass != null && 
-          ref.getQualifier() == null && 
-          containingClass.getTypeParameters().length > 0 && 
-          !((PsiClass)resolved).hasModifierProperty(PsiModifier.STATIC) && 
+      if (containingClass != null &&
+          ref.getQualifier() == null &&
+          containingClass.getTypeParameters().length > 0 &&
+          !((PsiClass)resolved).hasModifierProperty(PsiModifier.STATIC) &&
           ((PsiClass)resolved).getTypeParameters().length == 0) {
         String description = JavaErrorMessages.message("illegal.generic.type.for.instanceof");
         return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create();
@@ -1180,7 +1006,7 @@
       LOG.assertTrue(varParameter.isVarArgs());
       final PsiEllipsisType ellipsisType = (PsiEllipsisType)varParameter.getType();
       final PsiType componentType = ellipsisType.getComponentType();
-      if (isReifiableType(componentType)) {
+      if (JavaGenericsUtil.isReifiableType(componentType)) {
         PsiElement element = varParameter.getTypeElement();
         return HighlightInfo.newHighlightInfo(HighlightInfoType.WARNING).range(element).descriptionAndTooltip(
           "@SafeVarargs is not applicable for reifiable types").create();
@@ -1192,102 +1018,6 @@
     }
   }
 
-  public static boolean isUncheckedWarning(PsiJavaCodeReferenceElement expression, JavaResolveResult resolveResult) {
-    final PsiElement resolve = resolveResult.getElement();
-    if (resolve instanceof PsiMethod) {
-      final PsiMethod psiMethod = (PsiMethod)resolve;
-
-      final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(expression);
-
-      if (psiMethod.isVarArgs()) {
-        if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_7) || !AnnotationUtil.isAnnotated(psiMethod, "java.lang.SafeVarargs", false)) {
-          final int parametersCount = psiMethod.getParameterList().getParametersCount();
-          final PsiParameter varargParameter =
-            psiMethod.getParameterList().getParameters()[parametersCount - 1];
-          final PsiType componentType = ((PsiEllipsisType)varargParameter.getType()).getComponentType();
-          if (!isReifiableType(resolveResult.getSubstitutor().substitute(componentType))) {
-            final PsiElement parent = expression.getParent();
-            if (parent instanceof PsiCall) {
-              final PsiExpressionList argumentList = ((PsiCall)parent).getArgumentList();
-              if (argumentList != null) {
-                final PsiExpression[] args = argumentList.getExpressions();
-                if (args.length == parametersCount) {
-                  final PsiExpression lastArg = args[args.length - 1];
-                  if (lastArg instanceof PsiReferenceExpression) {
-                    final PsiElement lastArgsResolve = ((PsiReferenceExpression)lastArg).resolve();
-                    if (lastArgsResolve instanceof PsiParameter) {
-                      if (((PsiParameter)lastArgsResolve).getType() instanceof PsiArrayType) {
-                        return false;
-                      }
-                    }
-                  }
-                  else if (lastArg instanceof PsiMethodCallExpression) {
-                    if (lastArg.getType() instanceof PsiArrayType) {
-                      return false;
-                    }
-                  }
-                }
-                for (int i = parametersCount - 1; i < args.length; i++) {
-                  if (!isReifiableType(resolveResult.getSubstitutor().substitute(args[i].getType()))) {
-                    return true;
-                  }
-                }
-                return args.length < parametersCount;
-              }
-            }
-          }
-        }
-      }
-    }
-    return false;
-  }
-
-  public static boolean isReifiableType(PsiType type) {
-    if (type instanceof PsiArrayType) {
-      return isReifiableType(((PsiArrayType)type).getComponentType());
-    }
-
-    if (type instanceof PsiPrimitiveType) {
-      return true;
-    }
-
-    if (PsiUtil.resolveClassInType(type) instanceof PsiTypeParameter) {
-      return false;
-    }
-
-    if (type instanceof PsiClassType) {
-      final PsiClassType classType = (PsiClassType)PsiUtil.convertAnonymousToBaseType(type);
-      if (classType.isRaw()) {
-        return true;
-      }
-      PsiType[] parameters = classType.getParameters();
-
-      for (PsiType parameter : parameters) {
-        if (parameter instanceof PsiWildcardType && ((PsiWildcardType)parameter).getBound() == null) {
-          return true;
-        }
-      }
-      final PsiClass resolved = ((PsiClassType)PsiUtil.convertAnonymousToBaseType(classType)).resolve();
-      if (resolved instanceof PsiTypeParameter) {
-        return false;
-      }
-      if (parameters.length == 0) {
-        if (resolved != null && !resolved.hasModifierProperty(PsiModifier.STATIC)) {
-          final PsiClass containingClass = resolved.getContainingClass();
-          if (containingClass != null) {
-            final PsiTypeParameter[] containingClassTypeParameters = containingClass.getTypeParameters();
-            if (containingClassTypeParameters.length > 0) {
-              return false;
-            }
-          }
-        }
-        return true;
-      }
-    }
-
-    return false;
-  }
-
   static void checkEnumConstantForConstructorProblems(PsiEnumConstant enumConstant, final HighlightInfoHolder holder) {
     PsiClass containingClass = enumConstant.getContainingClass();
     if (enumConstant.getInitializingClass() == null) {
@@ -1407,7 +1137,7 @@
         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){
@@ -1520,8 +1250,8 @@
       if (qualifier instanceof PsiJavaCodeReferenceElement) {
         if (((PsiJavaCodeReferenceElement)qualifier).getTypeParameters().length > 0) {
           final PsiElement resolve = ((PsiJavaCodeReferenceElement)parent).resolve();
-          if (resolve instanceof PsiTypeParameterListOwner 
-              && ((PsiTypeParameterListOwner)resolve).hasTypeParameters() 
+          if (resolve instanceof PsiTypeParameterListOwner
+              && ((PsiTypeParameterListOwner)resolve).hasTypeParameters()
               && !((PsiTypeParameterListOwner)resolve).hasModifierProperty(PsiModifier.STATIC)) {
             return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parent).descriptionAndTooltip(
               "Improper formed type; some type parameters are missing").create();
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 62a59b0..40e1f57 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
@@ -98,7 +98,7 @@
       return null;
     }
     String baseClassName = HighlightUtil.formatClass(aClass, false);
-    String methodName = HighlightUtil.formatMethod(abstractMethod);
+    String methodName = JavaHighlightUtil.formatMethod(abstractMethod);
     String message = JavaErrorMessages.message(aClass instanceof PsiEnumConstantInitializer || implementsFixElement instanceof PsiEnumConstant ? "enum.constant.should.implement.method" : "class.must.be.abstract",
                                                baseClassName,
                                                methodName,
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMessageUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMessageUtil.java
deleted file mode 100644
index e15ab35..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMessageUtil.java
+++ /dev/null
@@ -1,65 +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.analysis;
-
-import com.intellij.lang.LangBundle;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiFormatUtil;
-import com.intellij.psi.util.PsiFormatUtilBase;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class HighlightMessageUtil {
-  private HighlightMessageUtil() { }
-
-  @Nullable
-  public static String getSymbolName(@NotNull PsiElement symbol, PsiSubstitutor substitutor) {
-    String symbolName = null;
-
-    if (symbol instanceof PsiClass) {
-      if (symbol instanceof PsiAnonymousClass) {
-        symbolName = LangBundle.message("java.terms.anonymous.class");
-      }
-      else {
-        symbolName = ((PsiClass)symbol).getQualifiedName();
-        if (symbolName == null) {
-          symbolName = ((PsiClass)symbol).getName();
-        }
-      }
-    }
-    else if (symbol instanceof PsiMethod) {
-      symbolName = PsiFormatUtil.formatMethod((PsiMethod)symbol,
-                                              substitutor, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS,
-                                              PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES);
-    }
-    else if (symbol instanceof PsiVariable) {
-      symbolName = ((PsiVariable)symbol).getName();
-    }
-    else if (symbol instanceof PsiPackage) {
-      symbolName = ((PsiPackage)symbol).getQualifiedName();
-    }
-    else if (symbol instanceof PsiFile) {
-      PsiDirectory directory = ((PsiFile)symbol).getContainingDirectory();
-      PsiPackage aPackage = directory == null ? null : JavaDirectoryService.getInstance().getPackage(directory);
-      symbolName = aPackage == null ? null : aPackage.getQualifiedName();
-    }
-    else if (symbol instanceof PsiDirectory) {
-      symbolName = ((PsiDirectory)symbol).getName();
-    }
-
-    return symbolName;
-  }
-}
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 1f5e33a..80f4b17 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
@@ -23,6 +23,7 @@
 import com.intellij.codeInsight.daemon.impl.quickfix.*;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInsight.intention.QuickFixFactory;
+import com.intellij.codeInspection.LocalQuickFixOnPsiElementAsIntentionAdapter;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.project.IndexNotReadyException;
 import com.intellij.openapi.util.Comparing;
@@ -60,8 +61,8 @@
   public static String createClashMethodMessage(PsiMethod method1, PsiMethod method2, boolean showContainingClasses) {
     @NonNls String pattern = showContainingClasses ? "clash.methods.message.show.classes" : "clash.methods.message";
     return JavaErrorMessages.message(pattern,
-                                     HighlightUtil.formatMethod(method1),
-                                     HighlightUtil.formatMethod(method2),
+                                     JavaHighlightUtil.formatMethod(method1),
+                                     JavaHighlightUtil.formatMethod(method2),
                                      HighlightUtil.formatClass(method1.getContainingClass()),
                                      HighlightUtil.formatClass(method2.getContainingClass()));
   }
@@ -212,8 +213,8 @@
     // strange things happen when super method is from Object and method from interface
     if (superMethod.hasModifierProperty(PsiModifier.FINAL)) {
       String description = JavaErrorMessages.message("final.method.override",
-                                                 HighlightUtil.formatMethod(method),
-                                                 HighlightUtil.formatMethod(superMethod),
+                                                 JavaHighlightUtil.formatMethod(method),
+                                                 JavaHighlightUtil.formatMethod(superMethod),
                                                  HighlightUtil.formatClass(superMethod.getContainingClass()));
       TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
       HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create();
@@ -265,7 +266,7 @@
         PsiClassType exception = checkedExceptions.get(index);
         String description = JavaErrorMessages.message("overridden.method.does.not.throw",
                                                    createClashMethodMessage(method, superMethod, true),
-                                                   HighlightUtil.formatType(exception));
+                                                   JavaHighlightUtil.formatType(exception));
         TextRange textRange;
         if (includeRealPositionInfo) {
           PsiElement exceptionContext = exceptionContexts.get(index);
@@ -275,8 +276,8 @@
           textRange = TextRange.EMPTY_RANGE;
         }
         HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create();
-        QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMethodThrowsFix(method, exception, false, false));
-        QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMethodThrowsFix(superMethod, exception, true, true));
+        QuickFixAction.registerQuickFixAction(errorResult, new LocalQuickFixOnPsiElementAsIntentionAdapter(QUICK_FIX_FACTORY.createMethodThrowsFix(method, exception, false, false)));
+        QuickFixAction.registerQuickFixAction(errorResult, new LocalQuickFixOnPsiElementAsIntentionAdapter(QUICK_FIX_FACTORY.createMethodThrowsFix(superMethod, exception, true, true)));
         return errorResult;
       }
     }
@@ -325,6 +326,9 @@
     if (resolved instanceof PsiMethod && resolveResult.isValidResult()) {
       TextRange fixRange = getFixRange(methodCall);
       highlightInfo = HighlightUtil.checkUnhandledExceptions(methodCall, fixRange);
+      if (highlightInfo == null && !LambdaUtil.isValidQualifier4InterfaceStaticMethodCall((PsiMethod)resolved, methodCall.getMethodExpression())) {
+        highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip("Static method may be invoked on containing interface class only").range(fixRange).create();
+      }
     }
     else {
       PsiMethod resolvedMethod = null;
@@ -683,7 +687,7 @@
       if (parameter != null) {
         PsiType type = substitutor.substitute(parameter.getType());
         s +=  "<font " + (mismatchColor == null ? "" : "color=" + mismatchColor) + ">" +
-              esctrim(showShort ? type.getPresentableText() : HighlightUtil.formatType(type))
+              esctrim(showShort ? type.getPresentableText() : JavaHighlightUtil.formatType(type))
               + "</font>"
               ;
       }
@@ -694,7 +698,7 @@
         PsiType type = expression.getType();
         s += "<font " + (mismatchColor == null ? "" : "color='" + mismatchColor + "'") + ">" +
                esctrim(expression.getText()) + "&nbsp;&nbsp;"+
-              (mismatchColor == null || type == null || type == PsiType.NULL ? "" : "("+esctrim(HighlightUtil.formatType(type))+")")
+              (mismatchColor == null || type == null || type == PsiType.NULL ? "" : "("+esctrim(JavaHighlightUtil.formatType(type))+")")
               + "</font>"
               ;
 
@@ -722,7 +726,7 @@
       @NonNls String mismatchColor = showShort ? null : UIUtil.isUnderDarcula() ? "ff6464" : "red";
       ms += "<td> " + "<b><nobr>" + (i == 0 ? "(" : "")
             + "<font " + (showShort ? "" : "color=" + mismatchColor) + ">" +
-            XmlStringUtil.escapeString(showShort ? type.getPresentableText() : HighlightUtil.formatType(type))
+            XmlStringUtil.escapeString(showShort ? type.getPresentableText() : JavaHighlightUtil.formatType(type))
             + "</font>"
             + (i == expressions.length - 1 ? ")" : ",") + "</nobr></b></td>";
     }
@@ -744,7 +748,7 @@
       ms += "<td><b><nobr>" + (i == 0 ? "(" : "") +
             XmlStringUtil.escapeString(showShortType(i, parameters, expressions, substitutor)
                                  ? type.getPresentableText()
-                                 : HighlightUtil.formatType(type))
+                                 : JavaHighlightUtil.formatType(type))
             + (i == parameters.length - 1 ? ")" : ",") + "</nobr></b></td>";
     }
     return ms;
@@ -849,7 +853,7 @@
     }
     if (methodCount > 1) {
       String description = JavaErrorMessages.message("duplicate.method",
-                                                 HighlightUtil.formatMethod(method),
+                                                 JavaHighlightUtil.formatMethod(method),
                                                  HighlightUtil.formatClass(aClass));
       TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
       return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create();
@@ -939,7 +943,7 @@
       PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expr.getParent().getParent();
       PsiMethod method = methodCallExpression.resolveMethod();
       if (method != null && method.hasModifierProperty(PsiModifier.ABSTRACT)) {
-        String message = JavaErrorMessages.message("direct.abstract.method.access", HighlightUtil.formatMethod(method));
+        String message = JavaErrorMessages.message("direct.abstract.method.access", JavaHighlightUtil.formatMethod(method));
         return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(methodCallExpression).descriptionAndTooltip(message).create();
       }
     }
@@ -1028,9 +1032,9 @@
                                 : "instance.method.cannot.override.static.method";
 
       String description = JavaErrorMessages.message(messageKey,
-                                                 HighlightUtil.formatMethod(method),
+                                                 JavaHighlightUtil.formatMethod(method),
                                                  HighlightUtil.formatClass(aClass),
-                                                 HighlightUtil.formatMethod(superMethod),
+                                                 JavaHighlightUtil.formatMethod(superMethod),
                                                  HighlightUtil.formatClass(superClass));
 
       HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create();
@@ -1128,9 +1132,9 @@
           PsiMethod superMethod = superSignature.getMethod();
           if (!superMethod.hasModifierProperty(PsiModifier.STATIC)) {
             description = JavaErrorMessages.message("static.method.cannot.override.instance.method",
-                                                         HighlightUtil.formatMethod(method),
+                                                         JavaHighlightUtil.formatMethod(method),
                                                          HighlightUtil.formatClass(containingClass),
-                                                         HighlightUtil.formatMethod(superMethod),
+                                                         JavaHighlightUtil.formatMethod(superMethod),
                                                          HighlightUtil.formatClass(superMethod.getContainingClass()));
             break Ultimate;
           }
@@ -1177,7 +1181,7 @@
     TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
     HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create();
     for (PsiClassType exception : unhandled) {
-      QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createMethodThrowsFix(method, exception, true, false));
+      QuickFixAction.registerQuickFixAction(highlightInfo, new LocalQuickFixOnPsiElementAsIntentionAdapter(QUICK_FIX_FACTORY.createMethodThrowsFix(method, exception, true, false)));
     }
     return highlightInfo;
   }
@@ -1380,43 +1384,6 @@
     }
   }
 
-  public static boolean isSerializationRelatedMethod(PsiMethod method, PsiClass containingClass) {
-    if (containingClass == null || method.isConstructor()) return false;
-    if (method.hasModifierProperty(PsiModifier.STATIC)) return false;
-    @NonNls String name = method.getName();
-    PsiParameter[] parameters = method.getParameterList().getParameters();
-    PsiType returnType = method.getReturnType();
-    if ("readObjectNoData".equals(name)) {
-      return parameters.length == 0 && TypeConversionUtil.isVoidType(returnType) && HighlightUtil.isSerializable(containingClass);
-    }
-    if ("readObject".equals(name)) {
-      return parameters.length == 1
-             && parameters[0].getType().equalsToText("java.io.ObjectInputStream")
-             && TypeConversionUtil.isVoidType(returnType) && method.hasModifierProperty(PsiModifier.PRIVATE)
-             && HighlightUtil.isSerializable(containingClass);
-    }
-    if ("readResolve".equals(name)) {
-      return parameters.length == 0
-             && returnType != null
-             && returnType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)
-             && (containingClass.hasModifierProperty(PsiModifier.ABSTRACT) || HighlightUtil.isSerializable(containingClass));
-    }
-    if ("writeReplace".equals(name)) {
-      return parameters.length == 0
-             && returnType != null
-             && returnType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)
-             && (containingClass.hasModifierProperty(PsiModifier.ABSTRACT) || HighlightUtil.isSerializable(containingClass));
-    }
-    if ("writeObject".equals(name)) {
-      return parameters.length == 1
-             && TypeConversionUtil.isVoidType(returnType)
-             && parameters[0].getType().equalsToText("java.io.ObjectOutputStream")
-             && method.hasModifierProperty(PsiModifier.PRIVATE)
-             && HighlightUtil.isSerializable(containingClass);
-    }
-    return false;
-  }
-
   private static String buildArgTypesList(PsiExpressionList list) {
     StringBuilder builder = new StringBuilder();
     builder.append("(");
@@ -1426,7 +1393,7 @@
         builder.append(", ");
       }
       PsiType argType = args[i].getType();
-      builder.append(argType != null ? HighlightUtil.formatType(argType) : "?");
+      builder.append(argType != null ? JavaHighlightUtil.formatType(argType) : "?");
     }
     builder.append(")");
     return builder.toString();
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 eb75a70..5354932 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
@@ -26,6 +26,7 @@
 import com.intellij.codeInsight.intention.QuickFixFactory;
 import com.intellij.codeInsight.quickfix.ChangeVariableTypeQuickFixProvider;
 import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider;
+import com.intellij.codeInspection.LocalQuickFixOnPsiElementAsIntentionAdapter;
 import com.intellij.lang.findUsages.LanguageFindUsages;
 import com.intellij.lang.java.JavaLanguage;
 import com.intellij.openapi.diagnostic.Logger;
@@ -280,7 +281,8 @@
     if (TypeConversionUtil.isPrimitiveAndNotNull(operandType)
         || TypeConversionUtil.isPrimitiveAndNotNull(checkType)
         || !TypeConversionUtil.areTypesConvertible(operandType, checkType)) {
-      String message = JavaErrorMessages.message("inconvertible.type.cast", formatType(operandType), formatType(checkType));
+      String message = JavaErrorMessages.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil
+        .formatType(checkType));
       return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
     }
     return null;
@@ -300,7 +302,8 @@
     if (operandType != null &&
         !TypeConversionUtil.areTypesConvertible(operandType, castType) &&
         !RedundantCastUtil.isInPolymorphicCall(expression)) {
-      String message = JavaErrorMessages.message("inconvertible.type.cast", formatType(operandType), formatType(castType));
+      String message = JavaErrorMessages.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil
+        .formatType(castType));
       return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
     }
 
@@ -347,8 +350,8 @@
         PsiType.getJavaLangObject(assignment.getManager(), assignment.getResolveScope()).equals(lType)) {
       String operatorText = operationSign.getText().substring(0, operationSign.getText().length() - 1);
       String message = JavaErrorMessages.message("binary.operator.not.applicable", operatorText,
-                                                 formatType(lType),
-                                                 formatType(rType));
+                                                 JavaHighlightUtil.formatType(lType),
+                                                 JavaHighlightUtil.formatType(rType));
 
       errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(assignment).descriptionAndTooltip(message).create();
       QuickFixAction.registerQuickFixAction(errorResult, new ChangeToAppendFix(eqOpSign, lType, assignment));
@@ -547,7 +550,7 @@
       @NotNull
       @Override
       public String fun(PsiClassType type) {
-        return formatType(type);
+        return JavaHighlightUtil.formatType(type);
       }
     }, ", ");
   }
@@ -630,24 +633,10 @@
   }
 
   @NotNull
-  public static String formatMethod(@NotNull PsiMethod method) {
-    return PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS,
-                                      PsiFormatUtilBase.SHOW_TYPE);
-  }
-
-  @NotNull
   public static String formatField(@NotNull PsiField field) {
     return PsiFormatUtil.formatVariable(field, PsiFormatUtilBase.SHOW_CONTAINING_CLASS | PsiFormatUtilBase.SHOW_NAME, PsiSubstitutor.EMPTY);
   }
 
-  @NotNull
-  public static String formatType(@Nullable PsiType type) {
-    if (type == null) return PsiKeyword.NULL;
-    String text = type.getInternalCanonicalText();
-    return text == null ? PsiKeyword.NULL : text;
-  }
-
-
   @Nullable
   public static HighlightInfo checkUnhandledExceptions(@NotNull final PsiElement element, @Nullable TextRange textRange) {
     final List<PsiClassType> unhandledExceptions = ExceptionUtil.getUnhandledExceptions(element);
@@ -1148,7 +1137,7 @@
       if (exceptionType.isAssignableFrom(caughtType) || caughtType.isAssignableFrom(exceptionType)) return null;
     }
 
-    final String description = JavaErrorMessages.message("exception.never.thrown.try", formatType(caughtType));
+    final String description = JavaErrorMessages.message("exception.never.thrown.try", JavaHighlightUtil.formatType(caughtType));
     final HighlightInfo errorResult =
       HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter).descriptionAndTooltip(description).create();
     QuickFixAction.registerQuickFixAction(errorResult, new DeleteCatchFix(parameter));
@@ -1173,7 +1162,7 @@
         }
       }
       if (!used) {
-        final String description = JavaErrorMessages.message("exception.never.thrown.try", formatType(catchType));
+        final String description = JavaErrorMessages.message("exception.never.thrown.try", JavaHighlightUtil.formatType(catchType));
         final HighlightInfo highlight =
           HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create();
         QuickFixAction.registerQuickFixAction(highlight, new DeleteMultiCatchFix(typeElement));
@@ -1267,7 +1256,8 @@
     if (type != null) {
       if (!isValidTypeForSwitchSelector(type, PsiUtil.isLanguageLevel7OrHigher(expression))) {
         String message =
-          JavaErrorMessages.message("incompatible.types", JavaErrorMessages.message("valid.switch.selector.types"), formatType(type));
+          JavaErrorMessages.message("incompatible.types", JavaErrorMessages.message("valid.switch.selector.types"), JavaHighlightUtil
+            .formatType(type));
         errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
         QuickFixAction.registerQuickFixAction(errorResult, new ConvertSwitchToIfIntention(statement));
         if (PsiType.LONG.equals(type) || PsiType.FLOAT.equals(type) || PsiType.DOUBLE.equals(type)) {
@@ -1312,8 +1302,8 @@
       if (!TypeConversionUtil.isBinaryOperatorApplicable(operationSign, lType, rType, false)) {
         PsiJavaToken token = expression.getTokenBeforeOperand(operand);
         String message = JavaErrorMessages.message("binary.operator.not.applicable", token.getText(),
-                                                   formatType(lType),
-                                                   formatType(rType));
+                                                   JavaHighlightUtil.formatType(lType),
+                                                   JavaHighlightUtil.formatType(rType));
         return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
       }
       lType = TypeConversionUtil.calcTypeForBinaryExpression(lType, rType, operationSign, true);
@@ -1328,7 +1318,7 @@
     if (token != null && expression != null && !TypeConversionUtil.isUnaryOperatorApplicable(token, expression)) {
       PsiType type = expression.getType();
       if (type == null) return null;
-      String message = JavaErrorMessages.message("unary.operator.not.applicable", token.getText(), formatType(type));
+      String message = JavaErrorMessages.message("unary.operator.not.applicable", token.getText(), JavaHighlightUtil.formatType(type));
 
       PsiElement parentExpr = token.getParent();
       HighlightInfo highlightInfo =
@@ -1510,7 +1500,7 @@
     final PsiType arrayExpressionType = arrayExpression.getType();
 
     if (arrayExpressionType != null && !(arrayExpressionType instanceof PsiArrayType)) {
-      final String description = JavaErrorMessages.message("array.type.expected", formatType(arrayExpressionType));
+      final String description = JavaErrorMessages.message("array.type.expected", JavaHighlightUtil.formatType(arrayExpressionType));
       final HighlightInfo info =
         HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(arrayExpression).descriptionAndTooltip(description).create();
       QuickFixAction.registerQuickFixAction(info, new ReplaceWithListAccessFix(arrayAccessExpression));
@@ -1560,12 +1550,12 @@
         result.add(info);
 
         if (!arrayTypeFixChecked) {
-          final PsiType checkResult = sameType(initializers);
+          final PsiType checkResult = JavaHighlightUtil.sameType(initializers);
           fix = checkResult != null ? new VariableArrayTypeFix(arrayInitializer, checkResult) : null;
           arrayTypeFixChecked = true;
         }
         if (fix != null) {
-          QuickFixAction.registerQuickFixAction(info, fix);
+          QuickFixAction.registerQuickFixAction(info, new LocalQuickFixOnPsiElementAsIntentionAdapter(fix));
         }
       }
     }
@@ -1573,40 +1563,10 @@
   }
 
   @Nullable
-  private static PsiType getArrayInitializerType(@NotNull final PsiArrayInitializerExpression element) {
-    final PsiType typeCheckResult = sameType(element.getInitializers());
-    if (typeCheckResult != null) {
-      return typeCheckResult.createArrayType();
-    }
-    return null;
-  }
-
-  @Nullable
-  public static PsiType sameType(@NotNull PsiExpression[] expressions) {
-    PsiType type = null;
-    for (PsiExpression expression : expressions) {
-      final PsiType currentType;
-      if (expression instanceof PsiArrayInitializerExpression) {
-        currentType = getArrayInitializerType((PsiArrayInitializerExpression)expression);
-      }
-      else {
-        currentType = expression.getType();
-      }
-      if (type == null) {
-        type = currentType;
-      }
-      else if (!type.equals(currentType)) {
-        return null;
-      }
-    }
-    return type;
-  }
-
-  @Nullable
   private static HighlightInfo checkArrayInitializerCompatibleTypes(@NotNull PsiExpression initializer, final PsiType componentType) {
     PsiType initializerType = initializer.getType();
     if (initializerType == null) {
-      String description = JavaErrorMessages.message("illegal.initializer", formatType(componentType));
+      String description = JavaErrorMessages.message("illegal.initializer", JavaHighlightUtil.formatType(componentType));
       return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(initializer).descriptionAndTooltip(description).create();
     }
     PsiExpression expression = initializer instanceof PsiArrayInitializerExpression ? null : initializer;
@@ -2333,7 +2293,8 @@
                                                redIfNotMatch(lRawType, assignable), requiredRow,
                                                redIfNotMatch(rRawType, assignable), foundRow);
 
-    String description = JavaErrorMessages.message("incompatible.types", formatType(lType1), formatType(rType1));
+    String description = JavaErrorMessages.message("incompatible.types", JavaHighlightUtil.formatType(lType1), JavaHighlightUtil
+      .formatType(rType1));
 
     return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).description(description).escapedToolTip(toolTip).navigationShift(navigationShift).create();
   }
@@ -2503,7 +2464,7 @@
   @NotNull
   private static String format(@NotNull PsiElement element) {
     if (element instanceof PsiClass) return formatClass((PsiClass)element);
-    if (element instanceof PsiMethod) return formatMethod((PsiMethod)element);
+    if (element instanceof PsiMethod) return JavaHighlightUtil.formatMethod((PsiMethod)element);
     if (element instanceof PsiField) return formatField((PsiField)element);
     return ElementDescriptionUtil.getElementDescription(element, HighlightUsagesDescriptionLocation.INSTANCE);
   }
@@ -2575,18 +2536,12 @@
   }
 
 
-  public static boolean isSerializable(@NotNull PsiClass aClass) {
-    PsiManager manager = aClass.getManager();
-    PsiClass serializableClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("java.io.Serializable", aClass.getResolveScope());
-    return serializableClass != null && aClass.isInheritor(serializableClass, true);
-  }
-
   public static boolean isSerializationImplicitlyUsedField(@NotNull PsiField field) {
     final String name = field.getName();
     if (!SERIAL_VERSION_UID_FIELD_NAME.equals(name) && !SERIAL_PERSISTENT_FIELDS_FIELD_NAME.equals(name)) return false;
     if (!field.hasModifierProperty(PsiModifier.STATIC)) return false;
     PsiClass aClass = field.getContainingClass();
-    return aClass == null || isSerializable(aClass);
+    return aClass == null || JavaHighlightUtil.isSerializable(aClass);
   }
 
   @Nullable
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
index 952cb60..1f92c42 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
@@ -26,7 +26,6 @@
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.IndexNotReadyException;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.projectRoots.JavaSdkVersion;
@@ -54,7 +53,7 @@
 import java.util.Map;
 import java.util.Set;
 
-public class HighlightVisitorImpl extends JavaElementVisitor implements HighlightVisitor, DumbAware {
+public class HighlightVisitorImpl extends JavaElementVisitor implements HighlightVisitor {
   private final PsiResolveHelper myResolveHelper;
 
   private HighlightInfoHolder myHolder;
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AccessStaticViaInstanceFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AccessStaticViaInstanceFix.java
index d96e461..9841643 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AccessStaticViaInstanceFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AccessStaticViaInstanceFix.java
@@ -21,8 +21,6 @@
 import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.codeInsight.highlighting.HighlightManager;
 import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
-import com.intellij.ide.DataManager;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
@@ -96,7 +94,7 @@
       final PsiExpression qualifierExpression = myExpression.getQualifierExpression();
       PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
       if (qualifierExpression != null) {
-        if (!checkSideEffects(project, containingClass, qualifierExpression, factory, myExpression)) return;
+        if (!checkSideEffects(project, containingClass, qualifierExpression, factory, myExpression,editor)) return;
         PsiElement newQualifier = qualifierExpression.replace(factory.createReferenceExpression(containingClass));
         PsiElement qualifiedWithClassName = myExpression.copy();
         newQualifier.delete();
@@ -110,68 +108,71 @@
     }
   }
 
-  private boolean checkSideEffects(final Project project, PsiClass containingClass, final PsiExpression qualifierExpression,
-                                   PsiElementFactory factory, final PsiElement myExpression) {
+  private boolean checkSideEffects(final Project project,
+                                   PsiClass containingClass,
+                                   final PsiExpression qualifierExpression,
+                                   PsiElementFactory factory,
+                                   final PsiElement myExpression,
+                                   Editor editor) {
     final List<PsiElement> sideEffects = new ArrayList<PsiElement>();
-    boolean hasSideEffects = RemoveUnusedVariableFix.checkSideEffects(qualifierExpression, null, sideEffects);
+    boolean hasSideEffects = RemoveUnusedVariableUtil.checkSideEffects(qualifierExpression, null, sideEffects);
     if (hasSideEffects && !myOnTheFly) return false;
-    if (hasSideEffects && !ApplicationManager.getApplication().isUnitTestMode()) {
-      final TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
-      final Editor editor = PlatformDataKeys.EDITOR.getData(DataManager.getInstance().getDataContext());
-      if (editor == null)
-        return false;
-      HighlightManager.getInstance(project).addOccurrenceHighlights(editor, PsiUtilCore.toPsiElementArray(sideEffects), attributes, true,
-                                                                    null);
-      try {
-        hasSideEffects = PsiUtil.isStatement(factory.createStatementFromText(qualifierExpression.getText(), qualifierExpression));
-      }
-      catch (IncorrectOperationException e) {
-        hasSideEffects = false;
-      }
-      final PsiReferenceExpression qualifiedWithClassName = (PsiReferenceExpression)myExpression.copy();
-      qualifiedWithClassName.setQualifierExpression(factory.createReferenceExpression(containingClass));
-      final boolean canCopeWithSideEffects = hasSideEffects;
-      final SideEffectWarningDialog dialog =
-        new SideEffectWarningDialog(project, false, null, sideEffects.get(0).getText(), PsiExpressionTrimRenderer.render(qualifierExpression),
-                                    canCopeWithSideEffects){
-          @Override
-          protected String sideEffectsDescription() {
-            if (canCopeWithSideEffects) {
-              return "<html><body>" +
-                     "  There are possible side effects found in expression '" +
-                     qualifierExpression.getText() +
-                     "'<br>" +
-                     "  You can:<ul><li><b>Remove</b> class reference along with whole expressions involved, or</li>" +
-                     "  <li><b>Transform</b> qualified expression into the statement on its own.<br>" +
-                     "  That is,<br>" +
-                     "  <table border=1><tr><td><code>" +
-                     myExpression.getText() +
-                     "</code></td></tr></table><br> becomes: <br>" +
-                     "  <table border=1><tr><td><code>" +
-                     qualifierExpression.getText() +
-                     ";<br>" +
-                     qualifiedWithClassName.getText() +
-                     "       </code></td></tr></table></li>" +
-                     "  </body></html>";
-            } else {
-              return "<html><body>  There are possible side effects found in expression '" + qualifierExpression.getText() + "'<br>" +
-                     "You can:<ul><li><b>Remove</b> class reference along with whole expressions involved, or</li></body></html>";
-            }
+    if (!hasSideEffects || ApplicationManager.getApplication().isUnitTestMode()) {
+      return true;
+    }
+    if (editor == null) {
+      return false;
+    }
+    TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
+    HighlightManager.getInstance(project).addOccurrenceHighlights(editor, PsiUtilCore.toPsiElementArray(sideEffects), attributes, true, null);
+    try {
+      hasSideEffects = PsiUtil.isStatement(factory.createStatementFromText(qualifierExpression.getText(), qualifierExpression));
+    }
+    catch (IncorrectOperationException e) {
+      hasSideEffects = false;
+    }
+    final PsiReferenceExpression qualifiedWithClassName = (PsiReferenceExpression)myExpression.copy();
+    qualifiedWithClassName.setQualifierExpression(factory.createReferenceExpression(containingClass));
+    final boolean canCopeWithSideEffects = hasSideEffects;
+    final SideEffectWarningDialog dialog =
+      new SideEffectWarningDialog(project, false, null, sideEffects.get(0).getText(), PsiExpressionTrimRenderer.render(qualifierExpression),
+                                  canCopeWithSideEffects){
+        @Override
+        protected String sideEffectsDescription() {
+          if (canCopeWithSideEffects) {
+            return "<html><body>" +
+                   "  There are possible side effects found in expression '" +
+                   qualifierExpression.getText() +
+                   "'<br>" +
+                   "  You can:<ul><li><b>Remove</b> class reference along with whole expressions involved, or</li>" +
+                   "  <li><b>Transform</b> qualified expression into the statement on its own.<br>" +
+                   "  That is,<br>" +
+                   "  <table border=1><tr><td><code>" +
+                   myExpression.getText() +
+                   "</code></td></tr></table><br> becomes: <br>" +
+                   "  <table border=1><tr><td><code>" +
+                   qualifierExpression.getText() +
+                   ";<br>" +
+                   qualifiedWithClassName.getText() +
+                   "       </code></td></tr></table></li>" +
+                   "  </body></html>";
           }
-        };
-      dialog.show();
-      int res = dialog.getExitCode();
-      if (res == SideEffectWarningDialog.CANCEL) return false;
-      try {
-        if (res == SideEffectWarningDialog.MAKE_STATEMENT) {
-          final PsiStatement statementFromText = factory.createStatementFromText(qualifierExpression.getText() + ";", null);
-          final PsiStatement statement = PsiTreeUtil.getParentOfType(myExpression, PsiStatement.class);
-          statement.getParent().addBefore(statementFromText, statement);
+          return "<html><body>  There are possible side effects found in expression '" + qualifierExpression.getText() + "'<br>" +
+                 "You can:<ul><li><b>Remove</b> class reference along with whole expressions involved, or</li></body></html>";
         }
+      };
+    dialog.show();
+    int res = dialog.getExitCode();
+    if (res == RemoveUnusedVariableUtil.CANCEL) return false;
+    try {
+      if (res == RemoveUnusedVariableUtil.MAKE_STATEMENT) {
+        final PsiStatement statementFromText = factory.createStatementFromText(qualifierExpression.getText() + ";", null);
+        final PsiStatement statement = PsiTreeUtil.getParentOfType(myExpression, PsiStatement.class);
+        statement.getParent().addBefore(statementFromText, statement);
       }
-      catch (IncorrectOperationException e) {
-        LOG.error(e);
-      }
+    }
+    catch (IncorrectOperationException e) {
+      LOG.error(e);
     }
     return true;
   }
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddVariableInitializerFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddVariableInitializerFix.java
index dff7b58..6bb1d53 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddVariableInitializerFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddVariableInitializerFix.java
@@ -16,7 +16,7 @@
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
 import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.openapi.diagnostic.Logger;
@@ -75,7 +75,7 @@
     else {
       LOG.error("Unknown variable type: "+myVariable);
     }
-    PsiVariable var = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(myVariable);
+    PsiVariable var = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(myVariable);
     TextRange range = var.getInitializer().getTextRange();
     int offset = range.getStartOffset();
     editor.getCaretModel().moveToOffset(offset);
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CastMethodArgumentFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CastMethodArgumentFix.java
index 554c87c..04a7b58 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CastMethodArgumentFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CastMethodArgumentFix.java
@@ -24,7 +24,7 @@
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
 import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.psi.*;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
@@ -38,10 +38,10 @@
   @NotNull
   public String getText() {
     if (myArgList.getExpressions().length == 1) {
-      return QuickFixBundle.message("cast.single.parameter.text", HighlightUtil.formatType(myToType));
+      return QuickFixBundle.message("cast.single.parameter.text", JavaHighlightUtil.formatType(myToType));
     }
 
-    return QuickFixBundle.message("cast.parameter.text", myIndex + 1, HighlightUtil.formatType(myToType));
+    return QuickFixBundle.message("cast.parameter.text", myIndex + 1, JavaHighlightUtil.formatType(myToType));
   }
 
   private static class MyFixerActionFactory extends ArgumentFixerActionFactory {
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java
index ba7171b..1fecce1 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java
@@ -19,7 +19,7 @@
 import com.intellij.codeInsight.TargetElementUtil;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.daemon.impl.HighlightInfo;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.find.FindManager;
 import com.intellij.find.findUsages.FindUsagesHandler;
@@ -90,7 +90,7 @@
     final String shortText = getShortText();
     if (shortText != null) return shortText;
     return QuickFixBundle.message("change.method.signature.from.usage.text",
-                                  HighlightUtil.formatMethod(myTargetMethod),
+                                  JavaHighlightUtil.formatMethod(myTargetMethod),
                                   myTargetMethod.getName(),
                                   formatTypesList(myNewParametersInfo, myContext));
   }
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeToAppendFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeToAppendFix.java
index 8c31230..0683af7 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeToAppendFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeToAppendFix.java
@@ -19,15 +19,13 @@
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.intention.IntentionAction;
+import com.intellij.codeInspection.util.ChangeToAppendUtil;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import com.intellij.psi.tree.IElementType;
-import com.intellij.psi.util.PsiUtil;
 import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 /**
  * @author Bas Leijdekkers
@@ -48,9 +46,10 @@
   @Override
   public String getText() {
     return QuickFixBundle.message("change.to.append.text",
-                                  buildAppendExpression(myAssignmentExpression.getRExpression(),
-                                                        myLhsType.equalsToText("java.lang.Appendable"),
-                                                        new StringBuilder(myAssignmentExpression.getLExpression().getText())));
+                                  ChangeToAppendUtil.buildAppendExpression(myAssignmentExpression.getRExpression(),
+                                                                           myLhsType.equalsToText("java.lang.Appendable"),
+                                                                           new StringBuilder(
+                                                                             myAssignmentExpression.getLExpression().getText())));
   }
 
   @NotNull
@@ -78,81 +77,8 @@
   public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
     if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
     final PsiExpression appendExpression =
-      buildAppendExpression(myAssignmentExpression.getLExpression(), myAssignmentExpression.getRExpression());
+      ChangeToAppendUtil.buildAppendExpression(myAssignmentExpression.getLExpression(), myAssignmentExpression.getRExpression());
     if (appendExpression == null) return;
     myAssignmentExpression.replace(appendExpression);
   }
-
-  @Nullable
-  public static PsiExpression buildAppendExpression(PsiExpression appendable, PsiExpression concatenation) {
-    if (concatenation == null) return null;
-    final PsiType type = appendable.getType();
-    if (type == null) return null;
-    final StringBuilder result =
-      buildAppendExpression(concatenation, type.equalsToText("java.lang.Appendable"), new StringBuilder(appendable.getText()));
-    if (result == null) return null;
-    final PsiElementFactory factory = JavaPsiFacade.getElementFactory(appendable.getProject());
-    return factory.createExpressionFromText(result.toString(), appendable);
-  }
-
-  @Nullable
-  private static StringBuilder buildAppendExpression(PsiExpression concatenation, boolean useStringValueOf, @NonNls StringBuilder out)
-    throws IncorrectOperationException {
-    final PsiType type = concatenation.getType();
-    if (type == null) {
-      return null;
-    }
-    if (concatenation instanceof PsiPolyadicExpression && type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
-      PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)concatenation;
-      final PsiExpression[] operands = polyadicExpression.getOperands();
-      boolean isConstant = true;
-      boolean isString = false;
-      final StringBuilder builder = new StringBuilder();
-      for (PsiExpression operand : operands) {
-        if (isConstant && PsiUtil.isConstantExpression(operand)) {
-          if (builder.length() != 0) {
-            builder.append('+');
-          }
-          final PsiType operandType = operand.getType();
-          if (operandType != null && operandType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
-            isString = true;
-          }
-          builder.append(operand.getText());
-        }
-        else {
-          isConstant = false;
-          if (builder.length() != 0) {
-            append(builder, useStringValueOf && !isString, out);
-            builder.setLength(0);
-          }
-          buildAppendExpression(operand, useStringValueOf, out);
-        }
-      }
-      if (builder.length() != 0) {
-        append(builder, false, out);
-      }
-    }
-    else if (concatenation instanceof PsiParenthesizedExpression) {
-      final PsiParenthesizedExpression parenthesizedExpression = (PsiParenthesizedExpression)concatenation;
-      final PsiExpression expression = parenthesizedExpression.getExpression();
-      if (expression != null) {
-        return buildAppendExpression(expression, useStringValueOf, out);
-      }
-    }
-    else {
-      append(concatenation.getText(), useStringValueOf && !type.equalsToText(CommonClassNames.JAVA_LANG_STRING), out);
-    }
-    return out;
-  }
-
-  private static void append(CharSequence text, boolean useStringValueOf, StringBuilder out) {
-    out.append(".append(");
-    if (useStringValueOf) {
-      out.append("String.valueOf(").append(text).append(')');
-    }
-    else {
-      out.append(text);
-    }
-    out.append(')');
-  }
 }
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java
index 9b20330..a996525 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java
@@ -92,7 +92,7 @@
     final boolean hadSideEffects;
     final String expressionText;
     final Project project = switchStatement.getProject();
-    if (RemoveUnusedVariableFix.checkSideEffects(switchExpression, null, new ArrayList<PsiElement>())) {
+    if (RemoveUnusedVariableUtil.checkSideEffects(switchExpression, null, new ArrayList<PsiElement>())) {
       hadSideEffects = true;
 
       final JavaCodeStyleManager javaCodeStyleManager =
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateCastExpressionFromInstanceofAction.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateCastExpressionFromInstanceofAction.java
index 35be223..ed56ce5 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateCastExpressionFromInstanceofAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateCastExpressionFromInstanceofAction.java
@@ -16,7 +16,7 @@
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
 import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
@@ -52,7 +52,7 @@
     assert instanceOfExpression.getContainingFile() == file : instanceOfExpression.getContainingFile() + "; file="+file;
     PsiElement decl = createAndInsertCast(instanceOfExpression, editor, file);
     if (decl == null) return;
-    decl = CodeStyleManager.getInstance(project).reformat(CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(decl));
+    decl = CodeStyleManager.getInstance(project).reformat(CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(decl));
     editor.getCaretModel().moveToOffset(decl.getTextRange().getEndOffset());
   }
 
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateClassFromNewFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateClassFromNewFix.java
index 43bd4c0..ff1b786 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateClassFromNewFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateClassFromNewFix.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.ExpectedTypeInfo;
 import com.intellij.codeInsight.ExpectedTypesProvider;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
@@ -100,7 +100,7 @@
       setupSuperCall(aClass, constructor, templateBuilder);
 
       getReferenceElement(newExpression).bindToElement(aClass);
-      aClass = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(aClass);
+      aClass = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(aClass);
       final Template template = templateBuilder.buildTemplate();
       template.setToReformat(true);
 
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 7074f27..fa32f9f 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
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.generation.OverrideImplementUtil;
 import com.intellij.codeInsight.template.Template;
@@ -65,7 +65,7 @@
                                                  getTargetSubstitutor(myConstructorCall));
       final PsiMethod superConstructor = CreateClassFromNewFix.setupSuperCall(targetClass, constructor, templateBuilder);
 
-      constructor = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(constructor);
+      constructor = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(constructor);
       Template template = templateBuilder.buildTemplate();
       final Editor editor = positionCursor(project, targetClass.getContainingFile(), targetClass);
       if (editor == null) return;
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromThisOrSuperFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromThisOrSuperFix.java
index 09fcdeb..f944fc7 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromThisOrSuperFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromThisOrSuperFix.java
@@ -16,7 +16,7 @@
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
 import com.intellij.codeInsight.CodeInsightUtil;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.template.Template;
 import com.intellij.codeInsight.template.TemplateBuilderImpl;
@@ -95,7 +95,7 @@
       templateBuilder.setEndVariableAfter(constructor.getBody().getLBrace());
       final RangeMarker rangeMarker = psiFile.getViewProvider().getDocument().createRangeMarker(myMethodCall.getTextRange());
 
-      constructor = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(constructor);
+      constructor = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(constructor);
 
       targetClass = constructor.getContainingClass();
       myMethodCall = CodeInsightUtil.findElementInRange(psiFile, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), myMethodCall.getClass());
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateEnumConstantFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateEnumConstantFromUsageFix.java
index 97c8f89..4972ed1 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateEnumConstantFromUsageFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateEnumConstantFromUsageFix.java
@@ -15,12 +15,11 @@
  */
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.ExpectedTypeInfo;
 import com.intellij.codeInsight.ExpectedTypeUtil;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.intention.HighPriorityAction;
-import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInsight.template.Template;
 import com.intellij.codeInsight.template.TemplateBuilderImpl;
 import com.intellij.openapi.diagnostic.Logger;
@@ -29,7 +28,6 @@
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.Function;
 import org.jetbrains.annotations.NotNull;
 
@@ -75,7 +73,7 @@
           builder.replaceElement(expression, new EmptyExpression());
         }
 
-        enumConstant = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(enumConstant);
+        enumConstant = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(enumConstant);
         final Template template = builder.buildTemplate();
 
         final Project project = targetClass.getProject();
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalFromUsageFix.java
index 41ffc74..24ba71d 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalFromUsageFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalFromUsageFix.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.intention.impl.TypeExpression;
 import com.intellij.codeInsight.template.Template;
@@ -110,7 +110,7 @@
       CodeStyleSettingsManager.getSettings(project).GENERATE_FINAL_LOCALS && !CreateFromUsageUtils.isAccessedForWriting(expressions);
     PsiUtil.setModifierProperty(var, PsiModifier.FINAL, isFinal);
 
-    var = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(var);
+    var = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(var);
     if (var == null) return;
     TemplateBuilderImpl builder = new TemplateBuilderImpl(var);
     builder.replaceElement(var.getTypeElement(), expression);
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalVarFromInstanceofAction.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalVarFromInstanceofAction.java
index e34cbb0..9fc885e 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalVarFromInstanceofAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalVarFromInstanceofAction.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.PsiEquivalenceUtil;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
@@ -206,7 +206,7 @@
       final PsiStatement statementInside = isNegated(instanceOfExpression) ? null : getExpressionStatementInside(file, editor, instanceOfExpression.getOperand());
       PsiDeclarationStatement decl = createLocalVariableDeclaration(instanceOfExpression, statementInside);
       if (decl == null) return;
-      decl = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(decl);
+      decl = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(decl);
 
       PsiLocalVariable localVariable = (PsiLocalVariable)decl.getDeclaredElements()[0];
       TemplateBuilderImpl builder = new TemplateBuilderImpl(localVariable);
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 a7cc465..d3fb2c1 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
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.ExpectedTypeInfo;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
@@ -214,7 +214,7 @@
                                ExpectedTypeInfo[] expectedTypes,
                                @Nullable final PsiElement context) {
 
-    method = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(method);
+    method = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(method);
 
     if (method == null) {
       return;
@@ -231,7 +231,7 @@
       .setupTypeElement(method.getReturnTypeElement(), expectedTypes, substitutor, builder, context, targetClass);
     PsiCodeBlock body = method.getBody();
     builder.setEndVariableAfter(shouldBeAbstract || body == null ? method : body.getLBrace());
-    method = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(method);
+    method = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(method);
     if (method == null) return;
 
     RangeMarker rangeMarker = document.createRangeMarker(method.getTextRange());
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java
index 2626335..c616859 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.completion.JavaLookupElementBuilder;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.intention.HighPriorityAction;
@@ -100,7 +100,7 @@
     if (classes.isEmpty()) return false;
 
     if (!checkTargetClasses(classes, methodName)) return false;
-    
+
     for (PsiClass aClass : classes) {
       if (!aClass.isInterface()) {
         setText(getterOrSetter);
@@ -242,13 +242,17 @@
     }
     accessor.setName(callText);
     PsiUtil.setModifierProperty(accessor, PsiModifier.STATIC, isStatic);
+    final String modifier = PsiUtil.getMaximumModifierForMember(targetClass);
+    if (modifier != null) {
+      PsiUtil.setModifierProperty(accessor, modifier, true);
+    }
 
     TemplateBuilderImpl builder = new TemplateBuilderImpl(accessor);
     builder.replaceElement(typeReference, TYPE_VARIABLE, new TypeExpression(project, expectedTypes), true);
     builder.replaceElement(fieldReference, FIELD_VARIABLE, new FieldExpression(field, targetClass, expectedTypes), true);
     builder.setEndVariableAfter(body.getLBrace());
 
-    accessor = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(accessor);
+    accessor = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(accessor);
     LOG.assertTrue(accessor != null);
     targetClass = accessor.getContainingClass();
     LOG.assertTrue(targetClass != null);
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteCatchFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteCatchFix.java
index 8ddf826..35d25d8 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteCatchFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteCatchFix.java
@@ -17,7 +17,7 @@
 
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
@@ -34,7 +34,7 @@
   @Override
   @NotNull
   public String getText() {
-    return QuickFixBundle.message("delete.catch.text", HighlightUtil.formatType(myCatchParameter.getType()));
+    return QuickFixBundle.message("delete.catch.text", JavaHighlightUtil.formatType(myCatchParameter.getType()));
   }
 
   @Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteMultiCatchFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteMultiCatchFix.java
index 69118b9..41e08d6 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteMultiCatchFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteMultiCatchFix.java
@@ -17,7 +17,7 @@
 
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
@@ -39,7 +39,7 @@
   @NotNull
   @Override
   public String getText() {
-    return QuickFixBundle.message("delete.catch.text", HighlightUtil.formatType(myTypeElement.getType()));
+    return QuickFixBundle.message("delete.catch.text", JavaHighlightUtil.formatType(myTypeElement.getType()));
   }
 
   @NotNull
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/GeneralizeCatchFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/GeneralizeCatchFix.java
index 4252711..b0c9790 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/GeneralizeCatchFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/GeneralizeCatchFix.java
@@ -17,7 +17,7 @@
 
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
@@ -41,8 +41,8 @@
   @NotNull
   public String getText() {
     return QuickFixBundle.message("generalize.catch.text",
-                                  HighlightUtil.formatType(myCatchParameter == null ? null : myCatchParameter.getType()),
-                                  HighlightUtil.formatType(myUnhandledException));
+                                  JavaHighlightUtil.formatType(myCatchParameter == null ? null : myCatchParameter.getType()),
+                                  JavaHighlightUtil.formatType(myUnhandledException));
   }
 
   @Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java
index ca346d3..a2bebf6 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java
@@ -108,7 +108,7 @@
   }
 
   @Override
-  protected List<PsiClass> filterByContext(List<PsiClass> candidates, PsiJavaCodeReferenceElement ref) {
+  protected List<PsiClass> filterByContext(@NotNull List<PsiClass> candidates, @NotNull PsiJavaCodeReferenceElement ref) {
     PsiElement typeElement = ref.getParent();
     if (typeElement instanceof PsiTypeElement) {
       PsiElement var = typeElement.getParent();
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java
index 1419aca..3e045a3 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java
@@ -58,6 +58,7 @@
  * @author peter
  */
 public abstract class ImportClassFixBase<T extends PsiElement, R extends PsiReference> implements HintAction, HighPriorityAction {
+  @NotNull
   private final T myElement;
   private final R myRef;
 
@@ -88,6 +89,13 @@
 
   @NotNull
   public List<PsiClass> getClassesToImport() {
+    if (myRef instanceof PsiJavaReference) {
+      JavaResolveResult result = ((PsiJavaReference)myRef).advancedResolve(true);
+      PsiElement element = result.getElement();
+      // already imported
+      // can happen when e.g. class name happened to be in a method position
+      if (element instanceof PsiClass && result.isValidResult()) return Collections.emptyList();
+    }
     PsiShortNamesCache cache = PsiShortNamesCache.getInstance(myElement.getProject());
     String name = getReferenceName(myRef);
     GlobalSearchScope scope = myElement.getResolveScope();
@@ -149,7 +157,7 @@
     return null;
   }
 
-  protected List<PsiClass> filterByContext(List<PsiClass> candidates, T ref) {
+  protected List<PsiClass> filterByContext(@NotNull List<PsiClass> candidates, @NotNull T ref) {
     return candidates;
   }
 
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/InitializeFinalFieldInConstructorFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/InitializeFinalFieldInConstructorFix.java
index 09053e5..ea5e364 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/InitializeFinalFieldInConstructorFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/InitializeFinalFieldInConstructorFix.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.generation.PsiMethodMember;
@@ -113,7 +113,7 @@
     T highest = null;
     int highestTextOffset = Integer.MAX_VALUE;
     for (T element : elements) {
-      final T forcedElem = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(element);
+      final T forcedElem = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(element);
       final int startOffset = forcedElem.getTextOffset();
       if (startOffset < highestTextOffset) {
         highest = forcedElem;
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/JavaCreateFieldFromUsageHelper.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/JavaCreateFieldFromUsageHelper.java
index 3fc0555..520f97f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/JavaCreateFieldFromUsageHelper.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/JavaCreateFieldFromUsageHelper.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.ExpectedTypeInfo;
 import com.intellij.codeInsight.template.Template;
 import com.intellij.codeInsight.template.TemplateBuilderImpl;
@@ -40,7 +40,7 @@
                                     PsiSubstitutor substitutor) {
     PsiElementFactory factory = JavaPsiFacade.getElementFactory(field.getProject());
 
-    field = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(field);
+    field = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(field);
     TemplateBuilderImpl builder = new TemplateBuilderImpl(field);
     if (!(expectedTypes instanceof ExpectedTypeInfo[])) {
       expectedTypes = ExpectedTypeInfo.EMPTY_ARRAY;
@@ -53,7 +53,7 @@
       builder.replaceElement(field.getInitializer(), new EmptyExpression());
       PsiIdentifier identifier = field.getNameIdentifier();
       builder.setEndVariableAfter(identifier);
-      field = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(field);
+      field = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(field);
     }
     editor.getCaretModel().moveToOffset(field.getTextRange().getStartOffset());
     Template template = builder.buildInlineTemplate();
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodThrowsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodThrowsFix.java
deleted file mode 100644
index 3ebfb21..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodThrowsFix.java
+++ /dev/null
@@ -1,107 +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.quickfix;
-
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
-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.PsiFormatUtil;
-import com.intellij.psi.util.PsiFormatUtilBase;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class MethodThrowsFix extends LocalQuickFixAndIntentionActionOnPsiElement {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.quickfix.MethodThrowsFix");
-
-  private final String myThrowsCanonicalText;
-  private final boolean myShouldThrow;
-  private final String myMethodName;
-
-  public MethodThrowsFix(PsiMethod method, PsiClassType exceptionType, boolean shouldThrow, boolean showContainingClass) {
-    super(method);
-    myThrowsCanonicalText = exceptionType.getCanonicalText();
-    myShouldThrow = shouldThrow;
-    myMethodName = PsiFormatUtil.formatMethod(method,
-                                              PsiSubstitutor.EMPTY,
-                                              PsiFormatUtilBase.SHOW_NAME | (showContainingClass ? PsiFormatUtilBase.SHOW_CONTAINING_CLASS
-                                                                                                   : 0),
-                                              0);
-  }
-
-  @NotNull
-  @Override
-  public String getText() {
-    return QuickFixBundle.message(myShouldThrow ? "fix.throws.list.add.exception" : "fix.throws.list.remove.exception",
-                                  myThrowsCanonicalText,
-                                  myMethodName);
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return QuickFixBundle.message("fix.throws.list.family");
-  }
-
-  @Override
-  public boolean isAvailable(@NotNull Project project,
-                             @NotNull PsiFile file,
-                             @NotNull PsiElement startElement,
-                             @NotNull PsiElement endElement) {
-    final PsiMethod myMethod = (PsiMethod)startElement;
-    return myMethod.isValid()
-        && myMethod.getManager().isInProject(myMethod);
-  }
-
-  @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 PsiMethod myMethod = (PsiMethod)startElement;
-    if (!FileModificationService.getInstance().prepareFileForWrite(myMethod.getContainingFile())) return;
-    PsiJavaCodeReferenceElement[] referenceElements = myMethod.getThrowsList().getReferenceElements();
-    try {
-      boolean alreadyThrows = false;
-      for (PsiJavaCodeReferenceElement referenceElement : referenceElements) {
-        if (referenceElement.getCanonicalText().equals(myThrowsCanonicalText)) {
-          alreadyThrows = true;
-          if (!myShouldThrow) {
-            referenceElement.delete();
-            break;
-          }
-        }
-      }
-      if (myShouldThrow && !alreadyThrows) {
-        final PsiElementFactory factory = JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory();
-        final PsiClassType type = (PsiClassType)factory.createTypeFromText(myThrowsCanonicalText, myMethod);
-        PsiJavaCodeReferenceElement ref = factory.createReferenceElementByType(type);
-        ref = (PsiJavaCodeReferenceElement)JavaCodeStyleManager.getInstance(project).shortenClassReferences(ref);
-        myMethod.getThrowsList().add(ref);
-      }
-      UndoUtil.markPsiFileForUndo(file);
-    } catch (IncorrectOperationException e) {
-      LOG.error(e);
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MoveCatchUpFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MoveCatchUpFix.java
index bdd618c..48fae89 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MoveCatchUpFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MoveCatchUpFix.java
@@ -17,7 +17,7 @@
 
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
@@ -44,8 +44,8 @@
   @NotNull
   public String getText() {
     return QuickFixBundle.message("move.catch.up.text",
-                                  HighlightUtil.formatType(myCatchSection.getCatchType()),
-                                  HighlightUtil.formatType(myMoveBeforeSection.getCatchType()));
+                                  JavaHighlightUtil.formatType(myCatchSection.getCatchType()),
+                                  JavaHighlightUtil.formatType(myMoveBeforeSection.getCatchType()));
   }
 
   @Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java
index 38f2c8a..8ca4195 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java
@@ -18,7 +18,7 @@
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.daemon.impl.HighlightInfo;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
@@ -50,7 +50,7 @@
   @NotNull
   @Override
   public String getText() {
-    return QuickFixBundle.message("remove.redundant.arguments.text", HighlightUtil.formatMethod(myTargetMethod));
+    return QuickFixBundle.message("remove.redundant.arguments.text", JavaHighlightUtil.formatMethod(myTargetMethod));
   }
 
   @NotNull
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableFix.java
index 3c67fa5..d779b1b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableFix.java
@@ -27,13 +27,8 @@
 import com.intellij.openapi.editor.markup.TextAttributes;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
-import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.psi.util.PsiExpressionTrimRenderer;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.PsiUtilCore;
-import com.intellij.refactoring.psi.PropertyUtils;
+import com.intellij.psi.util.*;
 import com.intellij.util.IncorrectOperationException;
-import gnu.trove.THashSet;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
@@ -75,21 +70,6 @@
     removeVariableAndReferencingStatements(editor);
   }
 
-  private static void deleteReferences(PsiVariable variable, List<PsiElement> references, int mode) throws IncorrectOperationException {
-    for (PsiElement expression : references) {
-      processUsage(expression, variable, null, mode);
-    }
-  }
-
-  private static void collectReferences(@NotNull PsiElement context, final PsiVariable variable, final List<PsiElement> references) {
-    context.accept(new JavaRecursiveElementWalkingVisitor() {
-      @Override public void visitReferenceExpression(PsiReferenceExpression expression) {
-        if (expression.resolve() == variable) references.add(expression);
-        super.visitReferenceExpression(expression);
-      }
-    });
-  }
-
   private void removeVariableAndReferencingStatements(Editor editor) {
     final List<PsiElement> references = new ArrayList<PsiElement>();
     final List<PsiElement> sideEffects = new ArrayList<PsiElement>();
@@ -97,13 +77,13 @@
     try {
       PsiElement context = myVariable instanceof PsiField ? ((PsiField)myVariable).getContainingClass() : PsiUtil.getVariableCodeBlock(myVariable, null);
       if (context != null) {
-        collectReferences(context, myVariable, references);
+        RemoveUnusedVariableUtil.collectReferences(context, myVariable, references);
       }
       // do not forget to delete variable declaration
       references.add(myVariable);
       // check for side effects
       for (PsiElement element : references) {
-        Boolean result = processUsage(element, myVariable, sideEffects, SideEffectWarningDialog.CANCEL);
+        Boolean result = RemoveUnusedVariableUtil.processUsage(element, myVariable, sideEffects, RemoveUnusedVariableUtil.CANCEL);
         if (result == null) return;
         canCopeWithSideEffects[0] &= result;
       }
@@ -118,7 +98,7 @@
       @Override
       public void run() {
         try {
-          deleteReferences(myVariable, references, deleteMode);
+          RemoveUnusedVariableUtil.deleteReferences(myVariable, references, deleteMode);
         }
         catch (IncorrectOperationException e) {
           LOG.error(e);
@@ -133,11 +113,11 @@
                                            boolean canCopeWithSideEffects,
                                            @NonNls String beforeText,
                                            @NonNls String afterText) {
-    if (sideEffects.isEmpty()) return SideEffectWarningDialog.DELETE_ALL;
+    if (sideEffects.isEmpty()) return RemoveUnusedVariableUtil.DELETE_ALL;
     if (ApplicationManager.getApplication().isUnitTestMode()) {
       return canCopeWithSideEffects
-             ? SideEffectWarningDialog.MAKE_STATEMENT
-             : SideEffectWarningDialog.DELETE_ALL;
+             ? RemoveUnusedVariableUtil.MAKE_STATEMENT
+             : RemoveUnusedVariableUtil.DELETE_ALL;
     }
     Project project = editor.getProject();
     HighlightManager highlightManager = HighlightManager.getInstance(project);
@@ -163,235 +143,16 @@
       final PsiElement sideEffect = sideEffects.get(0);
       if (sideEffect instanceof PsiExpression) {
         text = PsiExpressionTrimRenderer.render((PsiExpression)sideEffect);
-      } else {
+      }
+      else {
         text = sideEffect.getText();
       }
     }
     return showSideEffectsWarning(sideEffects, variable, editor, canCopeWithSideEffects, text, text);
   }
 
-  /**
-   *
-   * @param element
-   * @param variable
-   * @param sideEffects if null, delete usages, otherwise collect side effects
-   * @return true if there are at least one unrecoverable side effect found, false if no side effects,
-   *         null if read usage found (may happen if interval between fix creation in invoke() call was long enough)
-   * @throws IncorrectOperationException
-   */
-  private static Boolean processUsage(PsiElement element, PsiVariable variable, List<PsiElement> sideEffects, int deleteMode)
-    throws IncorrectOperationException {
-    if (!element.isValid()) return null;
-    PsiElementFactory factory = JavaPsiFacade.getInstance(variable.getProject()).getElementFactory();
-    while (element != null) {
-      if (element instanceof PsiAssignmentExpression) {
-        PsiAssignmentExpression expression = (PsiAssignmentExpression)element;
-        PsiExpression lExpression = expression.getLExpression();
-        // there should not be read access to the variable, otherwise it is not unused
-        if (!(lExpression instanceof PsiReferenceExpression) || variable != ((PsiReferenceExpression)lExpression).resolve()) {
-          return null;
-        }
-        PsiExpression rExpression = expression.getRExpression();
-        rExpression = PsiUtil.deparenthesizeExpression(rExpression);
-        if (rExpression == null) return true;
-        // replace assignment with expression and resimplify
-        boolean sideEffectFound = checkSideEffects(rExpression, variable, sideEffects);
-        if (!(element.getParent() instanceof PsiExpressionStatement) || PsiUtil.isStatement(rExpression)) {
-          if (deleteMode == SideEffectWarningDialog.MAKE_STATEMENT ||
-              deleteMode == SideEffectWarningDialog.DELETE_ALL && !(element.getParent() instanceof PsiExpressionStatement)) {
-            element = replaceElementWithExpression(rExpression, factory, element);
-            while (element.getParent() instanceof PsiParenthesizedExpression) {
-              element = element.getParent().replace(element);
-            }
-            List<PsiElement> references = new ArrayList<PsiElement>();
-            collectReferences(element, variable, references);
-            deleteReferences(variable, references, deleteMode);
-          }
-          else if (deleteMode == SideEffectWarningDialog.DELETE_ALL) {
-            deleteWholeStatement(element, factory);
-          }
-          return true;
-        }
-        else {
-          if (deleteMode != SideEffectWarningDialog.CANCEL) {
-            deleteWholeStatement(element, factory);
-          }
-          return !sideEffectFound;
-        }
-      }
-      else if (element instanceof PsiExpressionStatement && deleteMode != SideEffectWarningDialog.CANCEL) {
-        element.delete();
-        break;
-      }
-      else if (element instanceof PsiVariable && element == variable) {
-        PsiExpression expression = variable.getInitializer();
-        if (expression != null) {
-          expression = PsiUtil.deparenthesizeExpression(expression);
-        }
-        boolean sideEffectsFound = checkSideEffects(expression, variable, sideEffects);
-        if (expression != null && PsiUtil.isStatement(expression) && variable instanceof PsiLocalVariable
-            &&
-            !(variable.getParent() instanceof PsiDeclarationStatement &&
-              ((PsiDeclarationStatement)variable.getParent()).getDeclaredElements().length > 1)) {
-          if (deleteMode == SideEffectWarningDialog.MAKE_STATEMENT) {
-            element = element.replace(createStatementIfNeeded(expression, factory, element));
-            List<PsiElement> references = new ArrayList<PsiElement>();
-            collectReferences(element, variable, references);
-            deleteReferences(variable, references, deleteMode);
-          }
-          else if (deleteMode == SideEffectWarningDialog.DELETE_ALL) {
-            element.delete();
-          }
-          return true;
-        }
-        else {
-          if (deleteMode != SideEffectWarningDialog.CANCEL) {
-            if (element instanceof PsiField) {
-              ((PsiField)element).normalizeDeclaration();
-            }
-            element.delete();
-          }
-          return !sideEffectsFound;
-        }
-      }
-      element = element.getParent();
-    }
-    return true;
-  }
-
-  private static void deleteWholeStatement(PsiElement element, PsiElementFactory factory)
-    throws IncorrectOperationException {
-    // just delete it altogether
-    if (element.getParent() instanceof PsiExpressionStatement) {
-      PsiExpressionStatement parent = (PsiExpressionStatement)element.getParent();
-      if (parent.getParent() instanceof PsiCodeBlock) {
-        parent.delete();
-      }
-      else {
-        // replace with empty statement (to handle with 'if (..) i=0;' )
-        parent.replace(createStatementIfNeeded(null, factory, element));
-      }
-    }
-    else {
-      element.delete();
-    }
-  }
-
-  private static PsiElement createStatementIfNeeded(PsiExpression expression,
-                                                    PsiElementFactory factory,
-                                                    PsiElement element) throws IncorrectOperationException {
-    // if element used in expression, subexpression will do
-    if (!(element.getParent() instanceof PsiExpressionStatement) &&
-        !(element.getParent() instanceof PsiDeclarationStatement)) {
-      return expression;
-    }
-    return factory.createStatementFromText((expression == null ? "" : expression.getText()) + ";", null);
-  }
-
-  private static PsiElement replaceElementWithExpression(PsiExpression expression,
-                                                         PsiElementFactory factory,
-                                                         PsiElement element) throws IncorrectOperationException {
-    PsiElement elementToReplace = element;
-    PsiElement expressionToReplaceWith = expression;
-    if (element.getParent() instanceof PsiExpressionStatement) {
-      elementToReplace = element.getParent();
-      expressionToReplaceWith =
-      factory.createStatementFromText((expression == null ? "" : expression.getText()) + ";", null);
-    }
-    else if (element.getParent() instanceof PsiDeclarationStatement) {
-      expressionToReplaceWith =
-      factory.createStatementFromText((expression == null ? "" : expression.getText()) + ";", null);
-    }
-    return elementToReplace.replace(expressionToReplaceWith);
-  }
-
-    public static boolean checkSideEffects(PsiElement element, PsiVariable variable, List<PsiElement> sideEffects) {
-    if (sideEffects == null || element == null) return false;
-    if (element instanceof PsiMethodCallExpression) {
-      final PsiMethod psiMethod = ((PsiMethodCallExpression)element).resolveMethod();
-      if (psiMethod == null || !PropertyUtils.isSimpleGetter(psiMethod) && !PropertyUtils.isSimpleSetter(psiMethod)) {
-        sideEffects.add(element);
-        return true;
-      }
-    }
-    if (element instanceof PsiNewExpression) {
-      PsiNewExpression newExpression = (PsiNewExpression)element;
-      if (newExpression.getArrayDimensions().length == 0
-          && newExpression.getArrayInitializer() == null
-          && !isSideEffectFreeConstructor(newExpression)) {
-        sideEffects.add(element);
-        return true;
-      }
-    }
-    if (element instanceof PsiAssignmentExpression
-        && !(((PsiAssignmentExpression)element).getLExpression() instanceof PsiReferenceExpression
-             && ((PsiReferenceExpression)((PsiAssignmentExpression)element).getLExpression()).resolve() == variable)) {
-      sideEffects.add(element);
-      return true;
-    }
-    PsiElement[] children = element.getChildren();
-
-      for (PsiElement child : children) {
-        checkSideEffects(child, variable, sideEffects);
-      }
-    return !sideEffects.isEmpty();
-  }
-
-  private static final Set<String> ourSideEffectFreeClasses = new THashSet<String>();
-  static {
-    ourSideEffectFreeClasses.add(Object.class.getName());
-    ourSideEffectFreeClasses.add(Short.class.getName());
-    ourSideEffectFreeClasses.add(Character.class.getName());
-    ourSideEffectFreeClasses.add(Byte.class.getName());
-    ourSideEffectFreeClasses.add(Integer.class.getName());
-    ourSideEffectFreeClasses.add(Long.class.getName());
-    ourSideEffectFreeClasses.add(Float.class.getName());
-    ourSideEffectFreeClasses.add(Double.class.getName());
-    ourSideEffectFreeClasses.add(String.class.getName());
-    ourSideEffectFreeClasses.add(StringBuffer.class.getName());
-    ourSideEffectFreeClasses.add(Boolean.class.getName());
-
-    ourSideEffectFreeClasses.add(ArrayList.class.getName());
-    ourSideEffectFreeClasses.add(Date.class.getName());
-    ourSideEffectFreeClasses.add(HashMap.class.getName());
-    ourSideEffectFreeClasses.add(HashSet.class.getName());
-    ourSideEffectFreeClasses.add(Hashtable.class.getName());
-    ourSideEffectFreeClasses.add(LinkedHashMap.class.getName());
-    ourSideEffectFreeClasses.add(LinkedHashSet.class.getName());
-    ourSideEffectFreeClasses.add(LinkedList.class.getName());
-    ourSideEffectFreeClasses.add(Stack.class.getName());
-    ourSideEffectFreeClasses.add(TreeMap.class.getName());
-    ourSideEffectFreeClasses.add(TreeSet.class.getName());
-    ourSideEffectFreeClasses.add(Vector.class.getName());
-    ourSideEffectFreeClasses.add(WeakHashMap.class.getName());
-  }
-
-  private static boolean isSideEffectFreeConstructor(PsiNewExpression newExpression) {
-    PsiJavaCodeReferenceElement classReference = newExpression.getClassReference();
-    PsiClass aClass = classReference == null ? null : (PsiClass)classReference.resolve();
-    String qualifiedName = aClass == null ? null : aClass.getQualifiedName();
-    if (qualifiedName == null) return false;
-    if (ourSideEffectFreeClasses.contains(qualifiedName)) return true;
-
-    PsiFile file = aClass.getContainingFile();
-    PsiDirectory directory = file.getContainingDirectory();
-    PsiPackage classPackage = JavaDirectoryService.getInstance().getPackage(directory);
-    String packageName = classPackage == null ? null : classPackage.getQualifiedName();
-
-    // all Throwable descendants from java.lang are side effects free
-    if ("java.lang".equals(packageName) || "java.io".equals(packageName)) {
-      PsiClass throwableClass = JavaPsiFacade.getInstance(aClass.getProject()).findClass("java.lang.Throwable", aClass.getResolveScope());
-      if (throwableClass != null && InheritanceUtil.isInheritorOrSelf(aClass, throwableClass, true)) {
-        return true;
-      }
-    }
-    return false;
-  }
-
   @Override
   public boolean startInWriteAction() {
     return false;
   }
-
-
 }
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SideEffectWarningDialog.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SideEffectWarningDialog.java
index 5a15f0f..5f30a43 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SideEffectWarningDialog.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SideEffectWarningDialog.java
@@ -39,9 +39,6 @@
   private final boolean myCanCopeWithSideEffects;
   private AbstractAction myRemoveAllAction;
   private AbstractAction myCancelAllAction;
-  public static final int MAKE_STATEMENT = 1;
-  public static final int DELETE_ALL = 2;
-  public static final int CANCEL = 0;
 
   public SideEffectWarningDialog(Project project, boolean canBeParent, PsiVariable variable, String beforeText, String afterText, boolean canCopeWithSideEffects) {
     super(project, canBeParent);
@@ -66,7 +63,7 @@
 
       @Override
       public void actionPerformed(ActionEvent e) {
-        close(DELETE_ALL);
+        close(RemoveUnusedVariableUtil.DELETE_ALL);
       }
 
     };
@@ -79,7 +76,7 @@
 
         @Override
         public void actionPerformed(ActionEvent e) {
-          close(MAKE_STATEMENT);
+          close(RemoveUnusedVariableUtil.MAKE_STATEMENT);
         }
       };
       actions.add(makeStmtAction);
@@ -113,7 +110,7 @@
 
   @Override
   public void doCancelAction() {
-    close(CANCEL);
+    close(RemoveUnusedVariableUtil.CANCEL);
   }
 
   @Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java
deleted file mode 100644
index 83395ef..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java
+++ /dev/null
@@ -1,428 +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.
- */
-
-/**
- * @author cdr
- */
-package com.intellij.codeInsight.daemon.impl.quickfix;
-
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Ref;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.psi.tree.IElementType;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.util.Function;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class SimplifyBooleanExpressionFix implements IntentionAction {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.quickfix.SimplifyBooleanExpression");
-
-  private final PsiExpression mySubExpression;
-  private final Boolean mySubExpressionValue;
-
-  // subExpressionValue == Boolean.TRUE or Boolean.FALSE if subExpression evaluates to boolean constant and needs to be replaced
-  //   otherwise subExpressionValue= null and we starting to simplify expression without any further knowledge
-  public SimplifyBooleanExpressionFix(PsiExpression subExpression, Boolean subExpressionValue) {
-    mySubExpression = subExpression;
-    mySubExpressionValue = subExpressionValue;
-  }
-
-  @Override
-  @NotNull
-  public String getText() {
-    return QuickFixBundle.message("simplify.boolean.expression.text", mySubExpression.getText(), mySubExpressionValue);
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return QuickFixBundle.message("simplify.boolean.expression.family");
-  }
-
-  @Override
-  public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
-    return mySubExpression.isValid()
-           && mySubExpression.getManager().isInProject(mySubExpression)
-           && !PsiUtil.isAccessedForWriting(mySubExpression)
-      ;
-  }
-
-  @Override
-  public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
-    if (!isAvailable(project, editor, file)) return;
-    LOG.assertTrue(mySubExpression.isValid());
-    if (!FileModificationService.getInstance().preparePsiElementForWrite(mySubExpression)) return;
-    simplifyExpression(project, mySubExpression, mySubExpressionValue);
-  }
-
-  public static void simplifyExpression(Project project, final PsiExpression subExpression, final Boolean subExpressionValue) {
-    PsiExpression expression;
-    if (subExpressionValue == null) {
-      expression = subExpression;
-    }
-    else {
-      final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
-      final PsiExpression constExpression = factory.createExpressionFromText(Boolean.toString(subExpressionValue.booleanValue()), subExpression);
-      expression = (PsiExpression)subExpression.replace(constExpression);
-    }
-    while (expression.getParent() instanceof PsiExpression) {
-      expression = (PsiExpression)expression.getParent();
-    }
-    simplifyExpression(expression);
-  }
-
-  public static void simplifyIfStatement(final PsiExpression expression) throws IncorrectOperationException {
-    PsiElement parent = expression.getParent();
-    if (!(parent instanceof PsiIfStatement) || ((PsiIfStatement)parent).getCondition() != expression) return;
-    if (!(expression instanceof PsiLiteralExpression) || expression.getType() != PsiType.BOOLEAN) return;
-    boolean condition = Boolean.parseBoolean(expression.getText());
-    PsiIfStatement ifStatement = (PsiIfStatement)parent;
-    if (condition) {
-      replaceWithStatements(ifStatement, ifStatement.getThenBranch());
-    }
-    else {
-      PsiStatement elseBranch = ifStatement.getElseBranch();
-      if (elseBranch == null) {
-        ifStatement.delete();
-      }
-      else {
-        replaceWithStatements(ifStatement, elseBranch);
-      }
-    }
-  }
-
-  private static void replaceWithStatements(final PsiStatement orig, final PsiStatement statement) throws IncorrectOperationException {
-    if (statement == null) {
-      orig.delete();
-      return;
-    }
-    PsiElement parent = orig.getParent();
-    if (parent == null) return;
-    if (statement instanceof PsiBlockStatement && parent instanceof PsiCodeBlock) {
-      // See IDEADEV-24277
-      // Code block can only be inlined into another (parent) code block.
-      // Code blocks, which are if or loop statement branches should not be inlined.
-      PsiCodeBlock codeBlock = ((PsiBlockStatement)statement).getCodeBlock();
-      PsiJavaToken lBrace = codeBlock.getLBrace();
-      PsiJavaToken rBrace = codeBlock.getRBrace();
-      if (lBrace == null || rBrace == null) return;
-
-
-      final PsiElement[] children = codeBlock.getChildren();
-      if (children.length > 2) {
-        final PsiElement added =
-          parent.addRangeBefore(
-            children[1],
-            children[children.length - 2],
-            orig);
-        final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(orig.getManager());
-        codeStyleManager.reformat(added);
-      }
-      orig.delete();
-    }
-    else {
-      orig.replace(statement);
-    }
-  }
-
-  public static void simplifyExpression(PsiExpression expression) throws IncorrectOperationException {
-    final PsiExpression[] result = {(PsiExpression)expression.copy()};
-    final ExpressionVisitor expressionVisitor = new ExpressionVisitor(expression.getManager(), true);
-    final IncorrectOperationException[] exception = {null};
-    result[0].accept(new JavaRecursiveElementVisitor() {
-      @Override
-      public void visitElement(PsiElement element) {
-        // read in all children in advance since due to Igorek's exercises element replace involves its siblings invalidation
-        PsiElement[] children = element.getChildren();
-        for (PsiElement child : children) {
-          child.accept(this);
-        }
-      }
-
-      @Override
-      public void visitExpression(PsiExpression expression) {
-        super.visitExpression(expression);
-        expressionVisitor.clear();
-        expression.accept(expressionVisitor);
-        if (expressionVisitor.resultExpression != null) {
-          LOG.assertTrue(expressionVisitor.resultExpression.isValid());
-          try {
-            if (expression != result[0]) {
-              expression.replace(expressionVisitor.resultExpression);
-            }
-            else {
-              result[0] = expressionVisitor.resultExpression;
-            }
-          }
-          catch (IncorrectOperationException e) {
-            exception[0] = e;
-          }
-        }
-      }
-    });
-    if (exception[0] != null) {
-      throw exception[0];
-    }
-    PsiExpression newExpression = (PsiExpression)expression.replace(result[0]);
-    if (newExpression instanceof PsiLiteralExpression) {
-      final PsiElement parent = newExpression.getParent();
-      if (parent instanceof PsiAssertStatement && ((PsiLiteralExpression)newExpression).getValue() == Boolean.TRUE) {
-        parent.delete();
-        return;
-      }
-    }
-    simplifyIfStatement(newExpression);
-  }
-
-  public static boolean canBeSimplified(@NotNull PsiExpression expression) {
-    if (!(expression instanceof PsiConditionalExpression) && expression.getType() != PsiType.BOOLEAN) return false;
-
-    final ExpressionVisitor expressionVisitor = new ExpressionVisitor(expression.getManager(), false);
-    final Ref<Boolean> canBeSimplified = new Ref<Boolean>(Boolean.FALSE);
-    expression.accept(new JavaRecursiveElementWalkingVisitor() {
-      @Override
-      public void visitElement(PsiElement element) {
-        if (!canBeSimplified.get().booleanValue()) {
-          super.visitElement(element);
-        }
-      }
-
-      @Override
-      public void visitExpression(PsiExpression expression) {
-        super.visitExpression(expression);
-        expressionVisitor.clear();
-        expression.accept(expressionVisitor);
-        if (expressionVisitor.canBeSimplifiedFlag) {
-          canBeSimplified.set(Boolean.TRUE);
-        }
-      }
-    });
-    return canBeSimplified.get().booleanValue();
-  }
-
-  private static class ExpressionVisitor extends JavaElementVisitor {
-    private PsiExpression resultExpression;
-    private final PsiExpression trueExpression;
-    private final PsiExpression falseExpression;
-    private final boolean isCreateResult;
-    boolean canBeSimplifiedFlag;
-
-    private ExpressionVisitor(PsiManager psiManager, final boolean createResult) {
-      isCreateResult = createResult;
-      trueExpression = createResult ? createExpression(psiManager, Boolean.toString(true)) : null;
-      falseExpression = createResult ? createExpression(psiManager, Boolean.toString(false)) : null;
-    }
-
-    private static PsiExpression createExpression(final PsiManager psiManager, @NonNls String text) {
-      try {
-        return JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createExpressionFromText(text, null);
-      }
-      catch (IncorrectOperationException e) {
-        LOG.error(e);
-        return null;
-      }
-    }
-
-    private boolean markAndCheckCreateResult() {
-      canBeSimplifiedFlag = true;
-      return isCreateResult;
-    }
-
-    @Override
-    public void visitPolyadicExpression(PsiPolyadicExpression expression) {
-      PsiExpression[] operands = expression.getOperands();
-      PsiExpression lExpr = operands[0];
-      IElementType tokenType = expression.getOperationTokenType();
-      if (JavaTokenType.XOR == tokenType) {
-
-        boolean negate = false;
-        List<PsiExpression> expressions = new ArrayList<PsiExpression>();
-        for (PsiExpression operand : operands) {
-          final Boolean constBoolean = getConstBoolean(operand);
-          if (constBoolean != null) {
-            markAndCheckCreateResult();
-            if (constBoolean == Boolean.TRUE) {
-              negate = !negate;
-            }
-            continue;
-          }
-          expressions.add(operand);
-        }
-        if (expressions.isEmpty()) {
-          resultExpression = negate ? trueExpression : falseExpression;
-        } else {
-          String simplifiedText = StringUtil.join(expressions, new Function<PsiExpression, String>() {
-            @Override
-            public String fun(PsiExpression expression) {
-              return expression.getText();
-            }
-          }, " ^ ");
-          if (negate) {
-            if (expressions.size() > 1) {
-              simplifiedText = "!(" + simplifiedText + ")";
-            } else {
-              simplifiedText = "!" + simplifiedText;
-            }
-          }
-          resultExpression = JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(simplifiedText, expression);
-        }
-      } else {
-        for (int i = 1; i < operands.length; i++) {
-          Boolean l = getConstBoolean(lExpr);
-          PsiExpression operand = operands[i];
-          Boolean r = getConstBoolean(operand);
-          if (l != null) {
-            simplifyBinary(tokenType, l, operand);
-          }
-          else if (r != null) {
-            simplifyBinary(tokenType, r, lExpr);
-          }
-          else {
-            final PsiJavaToken javaToken = expression.getTokenBeforeOperand(operand);
-            if (javaToken != null && !PsiTreeUtil.hasErrorElements(operand) && !PsiTreeUtil.hasErrorElements(lExpr)) {
-              try {
-                resultExpression = JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(lExpr.getText() + javaToken.getText() + operand.getText(), expression);
-              }
-              catch (IncorrectOperationException e) {
-                resultExpression = null;
-              }
-            }
-            else {
-              resultExpression = null;
-            }
-          }
-          if (resultExpression != null) {
-            lExpr = resultExpression;
-          }
-        }
-      }
-    }
-
-    private void simplifyBinary(IElementType tokenType, Boolean lConstBoolean, PsiExpression rOperand) {
-      if (!markAndCheckCreateResult()) {
-        return;
-      }
-      if (JavaTokenType.ANDAND == tokenType || JavaTokenType.AND == tokenType) {
-        resultExpression = lConstBoolean.booleanValue() ? rOperand : falseExpression;
-      }
-      else if (JavaTokenType.OROR == tokenType || JavaTokenType.OR == tokenType) {
-        resultExpression = lConstBoolean.booleanValue() ? trueExpression : rOperand;
-      }
-      else if (JavaTokenType.EQEQ == tokenType) {
-        simplifyEquation(lConstBoolean, rOperand);
-      }
-      else if (JavaTokenType.NE == tokenType) {
-        PsiPrefixExpression negatedExpression = createNegatedExpression(rOperand);
-        resultExpression = negatedExpression;
-        visitPrefixExpression(negatedExpression);
-        simplifyEquation(lConstBoolean, resultExpression);
-      }
-    }
-
-    private void simplifyEquation(Boolean constBoolean, PsiExpression otherOperand) {
-      if (constBoolean.booleanValue()) {
-        resultExpression = otherOperand;
-      }
-      else {
-        PsiPrefixExpression negated = createNegatedExpression(otherOperand);
-        resultExpression = negated;
-        visitPrefixExpression(negated);
-      }
-    }
-
-    @Override
-    public void visitConditionalExpression(PsiConditionalExpression expression) {
-      Boolean condition = getConstBoolean(expression.getCondition());
-      if (condition == null) return;
-      if (!markAndCheckCreateResult()) {
-        return;
-      }
-      resultExpression = condition.booleanValue() ? expression.getThenExpression() : expression.getElseExpression();
-    }
-
-    private static PsiPrefixExpression createNegatedExpression(PsiExpression otherOperand) {
-      PsiPrefixExpression expression = (PsiPrefixExpression)createExpression(otherOperand.getManager(), "!(xxx)");
-      try {
-        expression.getOperand().replace(otherOperand);
-      }
-      catch (IncorrectOperationException e) {
-        LOG.error(e);
-      }
-      return expression;
-    }
-
-    @Override
-    public void visitPrefixExpression(PsiPrefixExpression expression) {
-      PsiExpression operand = expression.getOperand();
-      Boolean constBoolean = getConstBoolean(operand);
-      if (constBoolean == null) return;
-      IElementType tokenType = expression.getOperationTokenType();
-      if (JavaTokenType.EXCL == tokenType) {
-        if (!markAndCheckCreateResult()) {
-          return;
-        }
-        resultExpression = constBoolean.booleanValue() ? falseExpression : trueExpression;
-      }
-    }
-
-
-    @Override
-    public void visitParenthesizedExpression(PsiParenthesizedExpression expression) {
-      PsiExpression subexpr = expression.getExpression();
-      Boolean constBoolean = getConstBoolean(subexpr);
-      if (constBoolean == null) return;
-      if (!markAndCheckCreateResult()) {
-        return;
-      }
-      resultExpression = constBoolean.booleanValue() ? trueExpression : falseExpression;
-    }
-
-    @Override
-    public void visitReferenceExpression(PsiReferenceExpression expression) {
-      visitReferenceElement(expression);
-    }
-
-    public void clear() {
-      resultExpression = null;
-    }
-  }
-
-  public static Boolean getConstBoolean(PsiExpression operand) {
-    if (operand == null) return null;
-    operand = PsiUtil.deparenthesizeExpression(operand);
-    if (operand == null) return null;
-    String text = operand.getText();
-    return PsiKeyword.TRUE.equals(text) ? Boolean.TRUE : PsiKeyword.FALSE.equals(text) ? Boolean.FALSE : null;
-  }
-
-  @Override
-  public boolean startInWriteAction() {
-    return true;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SuperMethodReturnFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SuperMethodReturnFix.java
index 8ff371f..6f48890 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SuperMethodReturnFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SuperMethodReturnFix.java
@@ -17,7 +17,7 @@
 
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Editor;
@@ -52,7 +52,7 @@
     );
     return QuickFixBundle.message("fix.super.method.return.type.text",
                                   name,
-                                  HighlightUtil.formatType(mySuperMethodType));
+                                  JavaHighlightUtil.formatType(mySuperMethodType));
   }
 
   @Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableArrayTypeFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableArrayTypeFix.java
deleted file mode 100644
index 0b87b3d..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableArrayTypeFix.java
+++ /dev/null
@@ -1,182 +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.quickfix;
-
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
-import com.intellij.openapi.command.undo.UndoUtil;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class VariableArrayTypeFix extends LocalQuickFixAndIntentionActionOnPsiElement {
-
-  @NotNull
-  private final PsiArrayType myTargetType;
-  private final String myName;
-  private final String myFamilyName;
-
-  public VariableArrayTypeFix(@NotNull PsiArrayInitializerExpression initializer, @NotNull PsiType componentType) {
-    super(getInitializer(initializer));
-    PsiArrayType arrayType = new PsiArrayType(componentType);
-    PsiArrayInitializerExpression arrayInitializer = initializer;
-    while (arrayInitializer.getParent() instanceof PsiArrayInitializerExpression) {
-      arrayInitializer = (PsiArrayInitializerExpression)arrayInitializer.getParent();
-      arrayType = new PsiArrayType(arrayType);
-    }
-    myTargetType = arrayType;
-
-    PsiExpression myNewExpression = getNewExpressionLocal(arrayInitializer);
-    PsiVariable myVariable = getVariableLocal(arrayInitializer);
-    myName = myVariable == null ? null : myTargetType.equals(myVariable.getType()) && myNewExpression != null ?
-             QuickFixBundle.message("change.new.operator.type.text", getNewText(myNewExpression,arrayInitializer), myTargetType.getCanonicalText(), "") :
-             QuickFixBundle.message("fix.variable.type.text", myVariable.getName(), myTargetType.getCanonicalText());
-    myFamilyName = myVariable == null ? null : myTargetType.equals(myVariable.getType()) && myNewExpression != null ?
-                   QuickFixBundle.message("change.new.operator.type.family") :
-                   QuickFixBundle.message("fix.variable.type.family");
-  }
-
-  private static PsiArrayInitializerExpression getInitializer(PsiArrayInitializerExpression initializer) {
-    PsiArrayInitializerExpression arrayInitializer = initializer;
-    while (arrayInitializer.getParent() instanceof PsiArrayInitializerExpression) {
-      arrayInitializer = (PsiArrayInitializerExpression)arrayInitializer.getParent();
-    }
-
-    return arrayInitializer;
-  }
-
-  private static PsiVariable getVariableLocal(PsiArrayInitializerExpression initializer) {
-    PsiVariable variableLocal = null;
-
-    final PsiElement parent = initializer.getParent();
-    if (parent instanceof PsiVariable) {
-      variableLocal = (PsiVariable)parent;
-    }
-    else if (parent instanceof PsiNewExpression) {
-      PsiNewExpression newExpressionLocal = (PsiNewExpression)parent;
-      final PsiElement newParent = newExpressionLocal.getParent();
-      if (newParent instanceof PsiAssignmentExpression) {
-        variableLocal = getFromAssignment((PsiAssignmentExpression)newParent);
-      }
-      else if (newParent instanceof PsiVariable) {
-        variableLocal = (PsiVariable)newParent;
-      }
-    }
-    else if (parent instanceof PsiAssignmentExpression) {
-      variableLocal = getFromAssignment((PsiAssignmentExpression)parent);
-    }
-    return variableLocal;
-  }
-
-  private static PsiNewExpression getNewExpressionLocal(PsiArrayInitializerExpression initializer) {
-    PsiNewExpression newExpressionLocal = null;
-
-    final PsiElement parent = initializer.getParent();
-    if (parent instanceof PsiVariable) {
-
-    } else if (parent instanceof PsiNewExpression) {
-      newExpressionLocal = (PsiNewExpression) parent;
-    }
-
-    return newExpressionLocal;
-  }
-
-  @Nullable
-  private static PsiVariable getFromAssignment(final PsiAssignmentExpression assignment) {
-    final PsiExpression reference = assignment.getLExpression();
-    final PsiElement referencedElement = reference instanceof PsiReferenceExpression ? ((PsiReferenceExpression)reference).resolve() : null;
-    return referencedElement != null && referencedElement instanceof PsiVariable ? (PsiVariable)referencedElement : null;
-  }
-
-  private static String getNewText(PsiElement myNewExpression, PsiArrayInitializerExpression myInitializer) {
-    final String newText = myNewExpression.getText();
-    final int initializerIdx = newText.indexOf(myInitializer.getText());
-    if (initializerIdx != -1) {
-      return newText.substring(0, initializerIdx).trim();
-    }
-    return newText;
-  }
-
-  @NotNull
-  @Override
-  public String getText() {
-    return myName;
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return myFamilyName;
-  }
-
-  @Override
-  public boolean isAvailable(@NotNull Project project,
-                             @NotNull PsiFile file,
-                             @NotNull PsiElement startElement,
-                             @NotNull PsiElement endElement) {
-    final PsiArrayInitializerExpression myInitializer = (PsiArrayInitializerExpression)startElement;
-    final PsiVariable myVariable = getVariableLocal(myInitializer);
-
-    return myVariable != null
-           && myVariable.isValid()
-           && myVariable.getManager().isInProject(myVariable)
-           && myTargetType.isValid()
-           && myInitializer.isValid();
-  }
-
-  @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 PsiArrayInitializerExpression myInitializer = (PsiArrayInitializerExpression)startElement;
-    final PsiVariable myVariable = getVariableLocal(myInitializer);
-    if (myVariable == null) return;
-    /**
-     * only for the case when in same statement with initialization
-     */
-    final PsiNewExpression myNewExpression = getNewExpressionLocal(myInitializer);
-
-    if (!FileModificationService.getInstance().prepareFileForWrite(myVariable.getContainingFile())) return;
-    final PsiElementFactory factory = JavaPsiFacade.getInstance(file.getProject()).getElementFactory();
-
-    if (! myTargetType.equals(myVariable.getType())) {
-      myVariable.normalizeDeclaration();
-      myVariable.getTypeElement().replace(factory.createTypeElement(myTargetType));
-      JavaCodeStyleManager.getInstance(project).shortenClassReferences(myVariable);
-
-      if (! myVariable.getContainingFile().equals(file)) {
-        UndoUtil.markPsiFileForUndo(myVariable.getContainingFile());
-      }
-    }
-
-    if (myNewExpression != null) {
-      if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
-
-      @NonNls String text = "new " + myTargetType.getCanonicalText() + "{}";
-      final PsiNewExpression newExpression = (PsiNewExpression) factory.createExpressionFromText(text, myNewExpression.getParent());
-      final PsiElement[] children = newExpression.getChildren();
-      children[children.length - 1].replace(myInitializer);
-      myNewExpression.replace(newExpression);
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFix.java
index dad6f35..60e07b3 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFix.java
@@ -24,6 +24,7 @@
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.util.TypeConversionUtil;
@@ -31,6 +32,8 @@
 import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
 import com.intellij.refactoring.changeSignature.JavaChangeSignatureDialog;
 import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
+import com.intellij.refactoring.util.RefactoringUIUtil;
+import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -53,6 +56,7 @@
   @Override
   public String getText() {
     return QuickFixBundle.message("fix.variable.type.text",
+                                  UsageViewUtil.getType(getStartElement()),
                                   myName,
                                   getReturnType().getCanonicalText());
   }
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java
index 7fd7876..1b43c1b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java
@@ -33,6 +33,8 @@
 import com.intellij.refactoring.typeMigration.TypeMigrationLabeler;
 import com.intellij.refactoring.typeMigration.TypeMigrationProcessor;
 import com.intellij.refactoring.typeMigration.TypeMigrationRules;
+import com.intellij.usageView.UsageViewUtil;
+import com.intellij.usages.impl.UsageViewImpl;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 
@@ -49,6 +51,7 @@
   @NotNull
   public String getText() {
     return QuickFixBundle.message("fix.variable.type.text",
+                                  UsageViewUtil.getType(myVar),
                                   myVar.getName(),
                                   myExpressionType.getCanonicalText());
   }
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java
index 92b9c8a..85ea365 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@
       if (!((PsiJavaCodeReferenceElement)element).isQualified()) {
         final JavaResolveResult resolveResult = ((PsiJavaCodeReferenceElement)element).advancedResolve(false);
         final PsiElement refElement = resolveResult.getElement();
-        if (refElement != null && refElement.getContainingFile() != file) {
+        if (refElement != null) {
 
           if (refElement instanceof PsiClass) {
             if (refElement.getContainingFile() != element.getContainingFile()) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/DeclarationMover.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/DeclarationMover.java
index 4983733..25a1c5c 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/DeclarationMover.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/DeclarationMover.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.editorActions.moveUpDown;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
@@ -47,7 +47,7 @@
 
       try {
         PsiElement inserted = myEnumToInsertSemicolonAfter.getParent().addAfter(semicolon.getPsi(), myEnumToInsertSemicolonAfter);
-        inserted = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(inserted);
+        inserted = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(inserted);
         final LogicalPosition position = editor.offsetToLogicalPosition(inserted.getTextRange().getEndOffset());
 
         info.toMove2 = new LineRange(position.line + 1, position.line + 1);
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/StatementMover.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/StatementMover.java
index 3d1983d..6b82868 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/StatementMover.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/StatementMover.java
@@ -16,7 +16,7 @@
 package com.intellij.codeInsight.editorActions.moveUpDown;
 
 import com.intellij.codeInsight.CodeInsightUtil;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.lang.StdLanguages;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
@@ -60,7 +60,7 @@
       final PsiBlockStatement blockStatement = (PsiBlockStatement)factory.createStatementFromText("{}", statementToSurroundWithCodeBlock);
       blockStatement.getCodeBlock().replace(codeBlock);
       PsiBlockStatement newStatement = (PsiBlockStatement)statementToSurroundWithCodeBlock.replace(blockStatement);
-      newStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(newStatement);
+      newStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(newStatement);
       info.toMove = new LineRange(document.getLineNumber(lineRangeMarker.getStartOffset()), document.getLineNumber(lineRangeMarker.getEndOffset())+1);
       PsiCodeBlock newCodeBlock = newStatement.getCodeBlock();
       if (down) {
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 2c91b12..25eec5f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
@@ -28,7 +28,6 @@
 import com.intellij.psi.*;
 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;
@@ -263,10 +262,10 @@
       copyDocComment(sourceMethod, resultMethod);
       copyModifiers(sourceMethod.getModifierList(), resultMethod.getModifierList());
       final PsiSubstitutor collisionResolvedSubstitutor =
-        substituteTypeParameters(factory, target, sourceMethod.getTypeParameterList(), resultMethod.getTypeParameterList(), substitutor);
+        substituteTypeParameters(factory, target, sourceMethod.getTypeParameterList(), resultMethod.getTypeParameterList(), substitutor, sourceMethod);
       substituteReturnType(PsiManager.getInstance(project), resultMethod, sourceMethod.getReturnType(), collisionResolvedSubstitutor);
       substituteParameters(factory, codeStyleManager, sourceMethod.getParameterList(), resultMethod.getParameterList(), collisionResolvedSubstitutor, target);
-      substituteThrows(factory, sourceMethod.getThrowsList(), resultMethod.getThrowsList(), collisionResolvedSubstitutor);
+      substituteThrows(factory, sourceMethod.getThrowsList(), resultMethod.getThrowsList(), collisionResolvedSubstitutor, sourceMethod);
       return resultMethod;
     }
     catch (IncorrectOperationException e) {
@@ -285,14 +284,15 @@
                                                          @Nullable PsiElement target,
                                                          @Nullable PsiTypeParameterList sourceTypeParameterList,
                                                          @Nullable PsiTypeParameterList targetTypeParameterList,
-                                                         @NotNull PsiSubstitutor substitutor) {
+                                                         @NotNull PsiSubstitutor substitutor, 
+                                                         @NotNull PsiMethod sourceMethod) {
     if (sourceTypeParameterList == null || targetTypeParameterList == null) {
       return substitutor;
     }
 
     final Map<PsiTypeParameter, PsiType> substitutionMap = new HashMap<PsiTypeParameter, PsiType>(substitutor.getSubstitutionMap());
     for (PsiTypeParameter typeParam : sourceTypeParameterList.getTypeParameters()) {
-      final PsiTypeParameter substitutedTypeParam = substituteTypeParameter(factory, typeParam, substitutor);
+      final PsiTypeParameter substitutedTypeParam = substituteTypeParameter(factory, typeParam, substitutor, sourceMethod);
 
       final PsiTypeParameter resolvedTypeParam = resolveTypeParametersCollision(factory, sourceTypeParameterList, target, substitutedTypeParam, substitutor);
       targetTypeParameterList.add(resolvedTypeParam);
@@ -347,7 +347,8 @@
   @NotNull
   private static PsiTypeParameter substituteTypeParameter(final @NotNull JVMElementFactory factory,
                                                           @NotNull PsiTypeParameter typeParameter,
-                                                          final @NotNull PsiSubstitutor substitutor) {
+                                                          final @NotNull PsiSubstitutor substitutor, 
+                                                          @NotNull final PsiMethod sourceMethod) {
     final PsiElement copy = typeParameter.copy();
     final Map<PsiElement, PsiElement> replacementMap = new HashMap<PsiElement, PsiElement>();
     copy.accept(new JavaRecursiveElementVisitor() {
@@ -357,7 +358,7 @@
         final PsiElement resolve = reference.resolve();
         if (resolve instanceof PsiTypeParameter) {
           final PsiType type = factory.createType((PsiTypeParameter)resolve);
-          replacementMap.put(reference, factory.createReferenceElementByType((PsiClassType)substituteType(substitutor, type)));
+          replacementMap.put(reference, factory.createReferenceElementByType((PsiClassType)substituteType(substitutor, type, sourceMethod)));
         }
       }
     });
@@ -374,7 +375,7 @@
     for (int i = 0; i < parameters.length; i++) {
       PsiParameter parameter = parameters[i];
       final PsiType parameterType = parameter.getType();
-      final PsiType substituted = substituteType(substitutor, parameterType);
+      final PsiType substituted = substituteType(substitutor, parameterType, (PsiMethod)parameter.getDeclarationScope());
       @NonNls String paramName = parameter.getName();
       boolean isBaseNameGenerated = true;
       final boolean isSubstituted = substituted.equals(parameterType);
@@ -400,17 +401,20 @@
   private static void substituteThrows(@NotNull JVMElementFactory factory,
                                        @NotNull PsiReferenceList sourceThrowsList,
                                        @NotNull PsiReferenceList targetThrowsList,
-                                       @NotNull PsiSubstitutor substitutor) {
+                                       @NotNull PsiSubstitutor substitutor, 
+                                       @NotNull PsiMethod sourceMethod) {
     for (PsiClassType thrownType : sourceThrowsList.getReferencedTypes()) {
-      targetThrowsList.add(factory.createReferenceElementByType((PsiClassType)substituteType(substitutor, thrownType)));
+      targetThrowsList.add(factory.createReferenceElementByType((PsiClassType)substituteType(substitutor, thrownType, sourceMethod)));
     }
   }
 
   private static void copyDocComment(PsiMethod source, PsiMethod target) {
     final PsiElement navigationElement = source.getNavigationElement();
-    final PsiDocComment docComment = ((PsiDocCommentOwner)navigationElement).getDocComment();
-    if (docComment != null) {
-      target.addAfter(docComment, null);
+    if (navigationElement instanceof PsiDocCommentOwner) {
+      final PsiDocComment docComment = ((PsiDocCommentOwner)navigationElement).getDocComment();
+      if (docComment != null) {
+        target.addAfter(docComment, null);
+      }
     }
   }
 
@@ -431,7 +435,7 @@
     if (returnTypeElement == null || returnType == null) {
       return;
     }
-    final PsiType substitutedReturnType = substituteType(substitutor, returnType);
+    final PsiType substitutedReturnType = substituteType(substitutor, returnType, method);
 
     returnTypeElement.replace(new LightTypeElement(manager, substitutedReturnType instanceof PsiWildcardType ? TypeConversionUtil.erasure(substitutedReturnType) : substitutedReturnType));
   }
@@ -449,7 +453,10 @@
     return Arrays.asList(csManager.suggestVariableName(VariableKind.PARAMETER, null, null, parameterType).names).contains(paramName);
   }
 
-  private static PsiType substituteType(final PsiSubstitutor substitutor, final PsiType type) {
+  private static PsiType substituteType(final PsiSubstitutor substitutor, final PsiType type, @NotNull PsiTypeParameterListOwner owner) {
+    if (PsiUtil.isRawSubstitutor(owner, substitutor)) {
+      return TypeConversionUtil.erasure(type);
+    }
     final PsiType psiType = substitutor.substitute(type);
     if (psiType != null) {
       final PsiType deepComponentType = psiType.getDeepComponentType();
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/JavaOverrideImplementMemberChooser.java b/java/java-impl/src/com/intellij/codeInsight/generation/JavaOverrideImplementMemberChooser.java
new file mode 100644
index 0000000..3708b5e
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/JavaOverrideImplementMemberChooser.java
@@ -0,0 +1,224 @@
+package com.intellij.codeInsight.generation;
+
+import com.intellij.codeInsight.CodeInsightBundle;
+import com.intellij.icons.AllIcons;
+import com.intellij.ide.util.MemberChooser;
+import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.keymap.KeymapManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.util.NotNullLazyValue;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.infos.CandidateInfo;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * @author Dmitry Batkovich
+ */
+public class JavaOverrideImplementMemberChooser extends MemberChooser<PsiMethodMember> {
+  private static final String SORT_METHODS_BY_PERCENT_DESCRIPTION = "Sort by Percent of Classes which Overrides a Method";
+
+  @NonNls public static final String PROP_COMBINED_OVERRIDE_IMPLEMENT = "OverrideImplement.combined";
+  @NonNls public static final String PROP_OVERRIDING_SORTED_OVERRIDE_IMPLEMENT = "OverrideImplement.overriding.sorted";
+
+  private ToggleAction mySortByOverridingAction;
+  private ToggleAction myMergeAction;
+  private final PsiMethodMember[] myAllElements;
+  private final PsiMethodMember[] myOnlyPrimaryElements;
+  private final NotNullLazyValue<PsiMethodWithOverridingPercentMember[]> myLazyElementsWithPercent;
+  private final boolean myToImplement;
+  private Project myProject;
+  private boolean myMerge;
+  private boolean mySortedByOverriding;
+
+  @Nullable
+  public static JavaOverrideImplementMemberChooser create(final PsiElement aClass,
+                                                          final boolean toImplement,
+                                                          final Collection<CandidateInfo> candidates,
+                                                          final Collection<CandidateInfo> secondary) {
+    final Project project = aClass.getProject();
+    if (candidates.isEmpty() && secondary.isEmpty()) return null;
+
+    final PsiMethodMember[] onlyPrimary = convertToMethodMembers(candidates);
+    final PsiMethodMember[] all = ArrayUtil.mergeArrays(onlyPrimary, convertToMethodMembers(secondary));
+    final NotNullLazyValue<PsiMethodWithOverridingPercentMember[]> lazyElementsWithPercent =
+      new NotNullLazyValue<PsiMethodWithOverridingPercentMember[]>() {
+        @NotNull
+        @Override
+        protected PsiMethodWithOverridingPercentMember[] compute() {
+          final PsiMethodWithOverridingPercentMember[] elements =
+            PsiMethodWithOverridingPercentMember.calculateOverridingPercents(candidates);
+          Arrays.sort(elements, PsiMethodWithOverridingPercentMember.COMPARATOR);
+          return elements;
+        }
+      };
+    final boolean merge = PropertiesComponent.getInstance(project).getBoolean(PROP_COMBINED_OVERRIDE_IMPLEMENT, true);
+    final JavaOverrideImplementMemberChooser javaOverrideImplementMemberChooser =
+      new JavaOverrideImplementMemberChooser(all, onlyPrimary, lazyElementsWithPercent, project, PsiUtil.isLanguageLevel5OrHigher(aClass),
+                                             merge, toImplement, PropertiesComponent.getInstance(project)
+        .getBoolean(PROP_OVERRIDING_SORTED_OVERRIDE_IMPLEMENT, false));
+    javaOverrideImplementMemberChooser.setTitle(getChooserTitle(toImplement, merge));
+
+    javaOverrideImplementMemberChooser.setCopyJavadocVisible(true);
+
+    if (toImplement) {
+      javaOverrideImplementMemberChooser.selectElements(onlyPrimary);
+    }
+
+    if (ApplicationManager.getApplication().isUnitTestMode()) {
+      if (!toImplement || onlyPrimary.length == 0) {
+        javaOverrideImplementMemberChooser.selectElements(all);
+      }
+      javaOverrideImplementMemberChooser.close(DialogWrapper.OK_EXIT_CODE);
+      return javaOverrideImplementMemberChooser;
+    }
+    return javaOverrideImplementMemberChooser;
+  }
+
+  private JavaOverrideImplementMemberChooser(final PsiMethodMember[] allElements,
+                                             final PsiMethodMember[] onlyPrimaryElements,
+                                             final NotNullLazyValue<PsiMethodWithOverridingPercentMember[]> lazyElementsWithPercent,
+                                             final @NotNull Project project,
+                                             final boolean isInsertOverrideVisible,
+                                             final boolean merge,
+                                             final boolean toImplement,
+                                             final boolean sortedByOverriding) {
+    super(false, true, project, isInsertOverrideVisible, null, null);
+    myAllElements = allElements;
+    myOnlyPrimaryElements = onlyPrimaryElements;
+    myLazyElementsWithPercent = lazyElementsWithPercent;
+    myProject = project;
+    myMerge = merge;
+    myToImplement = toImplement;
+    mySortedByOverriding = sortedByOverriding;
+    resetElements(getInitialElements(allElements, onlyPrimaryElements, lazyElementsWithPercent, merge, toImplement, sortedByOverriding));
+    init();
+  }
+
+  private static PsiMethodMember[] getInitialElements(PsiMethodMember[] allElements,
+                                                      PsiMethodMember[] onlyPrimaryElements,
+                                                      NotNullLazyValue<PsiMethodWithOverridingPercentMember[]> lazyElementsWithPercent,
+                                                      boolean merge,
+                                                      boolean toImplement,
+                                                      boolean sortByOverriding) {
+    final boolean showElementsWithPercents = sortByOverriding && !toImplement;
+    final PsiMethodMember[] defaultElements = toImplement || merge ? allElements : onlyPrimaryElements;
+    return showElementsWithPercents ? lazyElementsWithPercent.getValue() : defaultElements;
+  }
+
+
+  @Override
+  protected void onAlphabeticalSortingEnabled(final AnActionEvent event) {
+    resetElements(myToImplement || myMerge ? myAllElements : myOnlyPrimaryElements, null, true);
+    if (mySortByOverridingAction != null) {
+      mySortByOverridingAction.setSelected(event, false);
+    }
+  }
+
+  @Override
+  protected void doOKAction() {
+    super.doOKAction();
+    PropertiesComponent.getInstance(myProject).setValue(PROP_COMBINED_OVERRIDE_IMPLEMENT, String.valueOf(myMerge));
+    PropertiesComponent.getInstance(myProject).setValue(PROP_OVERRIDING_SORTED_OVERRIDE_IMPLEMENT, String.valueOf(mySortedByOverriding));
+  }
+
+  @Override
+  protected void fillToolbarActions(DefaultActionGroup group) {
+    super.fillToolbarActions(group);
+    if (myToImplement) return;
+
+    mySortByOverridingAction = new MySortByOverridingAction();
+    if (mySortedByOverriding) {
+      changeSortComparator(PsiMethodWithOverridingPercentMember.COMPARATOR);
+    }
+    group.add(mySortByOverridingAction, Constraints.FIRST);
+
+    myMergeAction = new MyMergeAction();
+    group.add(myMergeAction);
+  }
+
+  private static String getChooserTitle(final boolean toImplement, final boolean merge) {
+    return toImplement
+           ? CodeInsightBundle.message("methods.to.implement.chooser.title")
+           : merge
+             ? CodeInsightBundle.message("methods.to.override.implement.chooser.title")
+             : CodeInsightBundle.message("methods.to.override.chooser.title");
+  }
+
+  private static PsiMethodMember[] convertToMethodMembers(Collection<CandidateInfo> candidates) {
+    return ContainerUtil.map2Array(candidates, PsiMethodMember.class, new Function<CandidateInfo, PsiMethodMember>() {
+      @Override
+      public PsiMethodMember fun(final CandidateInfo s) {
+        return new PsiMethodMember(s);
+      }
+    });
+  }
+
+  private class MySortByOverridingAction extends ToggleAction {
+    public MySortByOverridingAction() {
+      super(SORT_METHODS_BY_PERCENT_DESCRIPTION, SORT_METHODS_BY_PERCENT_DESCRIPTION, AllIcons.ObjectBrowser.SortedByUsage);
+      registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK)), myTree);
+    }
+
+    @Override
+    public boolean isSelected(final AnActionEvent e) {
+      return mySortedByOverriding;
+    }
+
+    @Override
+    public void setSelected(final AnActionEvent e, final boolean state) {
+      mySortedByOverriding = state;
+      if (state) {
+        if (myMerge) {
+          myMergeAction.setSelected(e, false);
+        }
+        disableAlphabeticalSorting(e);
+        final PsiMethodWithOverridingPercentMember[] elementsWithPercent = myLazyElementsWithPercent.getValue();
+        resetElements(elementsWithPercent, PsiMethodWithOverridingPercentMember.COMPARATOR, false);
+      }
+      else {
+        final PsiMethodMember[] elementsToRender = myMerge ? myAllElements : myOnlyPrimaryElements;
+        resetElementsWithDefaultComparator(elementsToRender, true);
+      }
+    }
+  }
+
+  private class MyMergeAction extends ToggleAction {
+    private MyMergeAction() {
+      super("Show methods to implement", "Show methods to implement", AllIcons.General.Show_to_implement);
+      registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.ALT_MASK)), myTree);
+      final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts("OverrideMethods");
+      registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree);
+    }
+
+    @Override
+    public boolean isSelected(AnActionEvent e) {
+      return myMerge;
+    }
+
+    @Override
+    public void setSelected(AnActionEvent e, boolean state) {
+      myMerge = state;
+      if (state && mySortByOverridingAction.isSelected(e)) {
+        mySortByOverridingAction.setSelected(e, false);
+      }
+      resetElements(state ? myAllElements : myOnlyPrimaryElements, null, true);
+      setTitle(getChooserTitle(false, myMerge));
+    }
+  }
+
+}
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 69205b4..68c3684 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 0-2 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.
@@ -22,15 +22,14 @@
 import com.intellij.codeInsight.intention.AddAnnotationFix;
 import com.intellij.featureStatistics.FeatureUsageTracker;
 import com.intellij.featureStatistics.ProductivityFeatureNames;
-import com.intellij.icons.AllIcons;
 import com.intellij.ide.fileTemplates.FileTemplate;
 import com.intellij.ide.fileTemplates.FileTemplateManager;
 import com.intellij.ide.fileTemplates.FileTemplateUtil;
 import com.intellij.ide.fileTemplates.JavaTemplateUtil;
 import com.intellij.ide.util.MemberChooser;
-import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.lang.java.JavaLanguage;
-import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.KeyboardShortcut;
+import com.intellij.openapi.actionSystem.Shortcut;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.Result;
 import com.intellij.openapi.command.WriteCommandAction;
@@ -49,8 +48,6 @@
 import com.intellij.openapi.project.Project;
 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;
@@ -61,7 +58,6 @@
 import com.intellij.psi.javadoc.PsiDocComment;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.*;
-import com.intellij.util.ArrayUtil;
 import com.intellij.util.Consumer;
 import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
@@ -72,15 +68,11 @@
 
 import javax.swing.*;
 import java.awt.event.ActionEvent;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
 import java.util.*;
 
 public class OverrideImplementUtil extends OverrideImplementExploreUtil {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.OverrideImplementUtil");
 
-  @NonNls private static final String PROP_COMBINED_OVERRIDE_IMPLEMENT = "OverrideImplement.combined";
-
   private OverrideImplementUtil() { }
 
   protected static MethodImplementor[] getImplementors() {
@@ -223,7 +215,7 @@
     }
 
     annotateOnOverrideImplement(result, aClass, method, insertOverrideIfPossible);
-    
+
     if (CodeStyleSettingsManager.getSettings(aClass.getProject()).REPEAT_SYNCHRONIZED && method.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
       result.getModifierList().setModifierProperty(PsiModifier.SYNCHRONIZED, true);
     }
@@ -379,7 +371,6 @@
       final PsiCodeBlock body = result.getBody();
       if (body != null) body.delete();
     }
-
     FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(template.getExtension());
     PsiType returnType = result.getReturnType();
     if (returnType == null) {
@@ -474,86 +465,29 @@
   public static MemberChooser<PsiMethodMember> showOverrideImplementChooser(Editor editor,
                                                                             final PsiElement aClass,
                                                                             final boolean toImplement,
-                                                                            Collection<CandidateInfo> candidates,
+                                                                            final Collection<CandidateInfo> candidates,
                                                                             Collection<CandidateInfo> secondary) {
+
+    final JavaOverrideImplementMemberChooser chooser =
+      JavaOverrideImplementMemberChooser.create(aClass, toImplement, candidates, secondary);
+    if (chooser == null) {
+      return null;
+    }
     Project project = aClass.getProject();
-    if (candidates.isEmpty() && secondary.isEmpty()) return null;
-
-    final PsiMethodMember[] onlyPrimary = convertToMethodMembers(candidates);
-    final PsiMethodMember[] all = ArrayUtil.mergeArrays(onlyPrimary, convertToMethodMembers(secondary));
-
-    final Ref<Boolean> merge = Ref.create(PropertiesComponent.getInstance(project).getBoolean(PROP_COMBINED_OVERRIDE_IMPLEMENT, true));
-    final MemberChooser<PsiMethodMember> chooser =
-      new MemberChooser<PsiMethodMember>(toImplement || merge.get() ? all : onlyPrimary, false, true, project, PsiUtil.isLanguageLevel5OrHigher(aClass)) {
-        @Override
-        protected void fillToolbarActions(DefaultActionGroup group) {
-          super.fillToolbarActions(group);
-          if (toImplement) return;
-
-          final ToggleAction mergeAction = new ToggleAction("Show methods to implement", "Show methods to implement",
-                                                            AllIcons.General.Show_to_implement) {
-            @Override
-            public boolean isSelected(AnActionEvent e) {
-              return merge.get().booleanValue();
-            }
-
-            @Override
-            public void setSelected(AnActionEvent e, boolean state) {
-              merge.set(state);
-              resetElements(state ? all : onlyPrimary);
-              setTitle(getChooserTitle(false, merge));
-            }
-          };
-          mergeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.ALT_MASK)), myTree);
-
-          Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts("OverrideMethods");
-          mergeAction.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree);
-
-          group.add(mergeAction);
-        }
-      };
-    chooser.setTitle(getChooserTitle(toImplement, merge));
     registerHandlerForComplementaryAction(project, editor, aClass, toImplement, chooser);
 
-    chooser.setCopyJavadocVisible(true);
-
-    if (toImplement) {
-      chooser.selectElements(onlyPrimary);
-    }
-
     if (ApplicationManager.getApplication().isUnitTestMode()) {
-      if (!toImplement || onlyPrimary.length == 0) {
-        chooser.selectElements(all);
-      }
-      chooser.close(DialogWrapper.OK_EXIT_CODE);
       return chooser;
     }
-
     chooser.show();
     if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) return null;
 
-    PropertiesComponent.getInstance(project).setValue(PROP_COMBINED_OVERRIDE_IMPLEMENT, merge.get().toString());
     return chooser;
   }
 
-  private static String getChooserTitle(boolean toImplement, Ref<Boolean> merge) {
-    return toImplement
-                     ? CodeInsightBundle.message("methods.to.implement.chooser.title")
-                     : merge.get().booleanValue()
-                       ? CodeInsightBundle.message("methods.to.override.implement.chooser.title")
-                       : CodeInsightBundle.message("methods.to.override.chooser.title");
-  }
-
-  private static PsiMethodMember[] convertToMethodMembers(Collection<CandidateInfo> candidates) {
-    return ContainerUtil.map2Array(candidates, PsiMethodMember.class, new Function<CandidateInfo, PsiMethodMember>() {
-        @Override
-        public PsiMethodMember fun(final CandidateInfo s) {
-          return new PsiMethodMember(s);
-        }
-      });
-  }
-
-  private static void registerHandlerForComplementaryAction(final Project project, final Editor editor, final PsiElement aClass,
+  private static void registerHandlerForComplementaryAction(final Project project,
+                                                            final Editor editor,
+                                                            final PsiElement aClass,
                                                             final boolean toImplement,
                                                             final MemberChooser<PsiMethodMember> chooser) {
     final JComponent preferredFocusedComponent = chooser.getPreferredFocusedComponent();
@@ -712,4 +646,4 @@
     boolean insert = CodeStyleSettingsManager.getSettings(aClass.getProject()).INSERT_OVERRIDE_ANNOTATION;
     return overrideOrImplementMethodCandidates(aClass, candidatesToImplement, copyJavadoc, insert);
   }
-}
+}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/PsiMethodWithOverridingPercentMember.java b/java/java-impl/src/com/intellij/codeInsight/generation/PsiMethodWithOverridingPercentMember.java
new file mode 100644
index 0000000..1d57d32
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/PsiMethodWithOverridingPercentMember.java
@@ -0,0 +1,157 @@
+package com.intellij.codeInsight.generation;
+
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.*;
+import com.intellij.psi.impl.source.PsiExtensibleClass;
+import com.intellij.psi.infos.CandidateInfo;
+import com.intellij.psi.search.searches.ClassInheritorsSearch;
+import com.intellij.ui.SimpleColoredComponent;
+import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
+
+import javax.swing.*;
+import java.util.*;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class PsiMethodWithOverridingPercentMember extends PsiMethodMember {
+
+  private final int myOverridingPercent;
+
+  public PsiMethodWithOverridingPercentMember(final CandidateInfo info, final int overridingPercent) {
+    super(info);
+    myOverridingPercent = overridingPercent;
+  }
+
+  @Override
+  public void renderTreeNode(final SimpleColoredComponent component, final JTree tree) {
+    component.append(myOverridingPercent + "% ", SimpleTextAttributes.GRAY_ATTRIBUTES);
+    super.renderTreeNode(component, tree);
+  }
+
+  @TestOnly
+  public int getOverridingPercent() {
+    return myOverridingPercent;
+  }
+
+  public static final Comparator<PsiMethodMember> COMPARATOR = new Comparator<PsiMethodMember>() {
+    @Override
+    public int compare(PsiMethodMember e1, PsiMethodMember e2) {
+      if (!(e1 instanceof PsiMethodWithOverridingPercentMember)) {
+        if (!(e2 instanceof PsiMethodWithOverridingPercentMember)) {
+          return e1.equals(e2) ? 0 : -1;
+        } else {
+          return -1;
+        }
+      }
+
+
+      if (!(e2 instanceof PsiMethodWithOverridingPercentMember)) {
+        return 1;
+      }
+      int sub =
+        ((PsiMethodWithOverridingPercentMember)e2).myOverridingPercent - ((PsiMethodWithOverridingPercentMember)e1).myOverridingPercent;
+      if (sub != 0) return sub;
+      return String.CASE_INSENSITIVE_ORDER.compare(e1.getText(), e2.getText());
+    }
+  };
+
+  @NotNull
+  public static PsiMethodWithOverridingPercentMember[] calculateOverridingPercents(@NotNull final Collection<CandidateInfo> candidateInfos) {
+    final List<PsiMethodWithOverridingPercentMember> result = new ArrayList<PsiMethodWithOverridingPercentMember>(candidateInfos.size());
+    final Map<String, Collection<PsiClass>> classShortNames2Inheritors = new HashMap<String, Collection<PsiClass>>();
+    for (final CandidateInfo candidateInfo : candidateInfos) {
+      final PsiMethod method = (PsiMethod)candidateInfo.getElement();
+      if (!method.hasModifierProperty(PsiModifier.FINAL) &&
+          !method.isConstructor() &&
+          !method.isDeprecated() &&
+          !EXCLUDED_JAVA_LANG_OBJECT_METHOD_NAMES.contains(method.getName())) {
+        final PsiClass containingClass = method.getContainingClass();
+        if (containingClass == null) {
+          continue;
+        }
+
+        final String classShortName = containingClass.getName();
+
+        Collection<PsiClass> allInheritors = classShortNames2Inheritors.get(classShortName);
+        if (allInheritors == null) {
+          allInheritors = ClassInheritorsSearch.search(containingClass, true).findAll();
+          classShortNames2Inheritors.put(classShortName, allInheritors);
+        }
+
+        final int allInheritorsCount = allInheritors.size() - 1;
+        if (allInheritorsCount > 0) {
+          final int percent = searchForOverridingCount(method, allInheritors) * 100 / allInheritorsCount;
+          if (percent > 1) {
+            result.add(new PsiMethodWithOverridingPercentMember(candidateInfo, percent));
+          }
+        }
+      }
+    }
+    return result.toArray(new PsiMethodWithOverridingPercentMember[result.size()]);
+  }
+
+  private static int searchForOverridingCount(final PsiMethod method, final Collection<PsiClass> containingClassInheritors) {
+    int counter = 0;
+    for (final PsiClass inheritor : containingClassInheritors) {
+      if (inheritor instanceof PsiExtensibleClass) {
+        final List<PsiMethod> ownMethods = ((PsiExtensibleClass)inheritor).getOwnMethods();
+        for (PsiMethod ownMethod : ownMethods) {
+          if (maybeSuper(method, ownMethod)) {
+            counter++;
+            break;
+          }
+        }
+
+      }
+    }
+    return counter;
+  }
+
+  private static boolean maybeSuper(@NotNull final PsiMethod superMethod, @NotNull final PsiMethod method) {
+    if (!superMethod.getName().equals(method.getName())) {
+      return false;
+    }
+    final PsiParameterList superMethodParameterList = superMethod.getParameterList();
+    final PsiParameterList methodParameterList = method.getParameterList();
+    if (superMethodParameterList.getParametersCount() != methodParameterList.getParametersCount()) {
+      return false;
+    }
+    final PsiParameter[] superMethodParameters = superMethodParameterList.getParameters();
+    final PsiParameter[] methodParameters = methodParameterList.getParameters();
+    for (int i = 0; i < methodParameters.length; i++) {
+      if (!StringUtil.equals(getTypeShortName(superMethodParameters[i].getType()), getTypeShortName(methodParameters[i].getType()))) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  @Nullable
+  private static String getTypeShortName(@NotNull final PsiType type) {
+    if (type instanceof PsiPrimitiveType) {
+      return ((PsiPrimitiveType)type).getBoxedTypeName();
+    }
+    if (type instanceof PsiClassType) {
+      return ((PsiClassType)type).getClassName();
+    }
+    if (type instanceof PsiArrayType) {
+      return getTypeShortName(((PsiArrayType)type).getComponentType()) + "[]";
+    }
+    return null;
+  }
+
+  private static final Set<String> EXCLUDED_JAVA_LANG_OBJECT_METHOD_NAMES =
+    ContainerUtil.newHashSet("hashCode", "finalize", "clone", "equals", "toString");
+
+  @Override
+  public String toString() {
+    return "PsiMethodWithOverridingPercentMember{" +
+           "myOverridingPercent=" + myOverridingPercent + ", myElement=" + getElement() +
+           '}';
+  }
+}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java b/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java
index baa5638..81a98e9 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java
@@ -21,6 +21,7 @@
 
 import com.intellij.codeInsight.CodeInsightActionHandler;
 import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.generation.OverrideImplementUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.editor.Editor;
@@ -53,7 +54,7 @@
       else {
         toGo = body.addAfter(superCall, body.getLBrace());
       }
-      toGo = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(toGo);
+      toGo = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(toGo);
       editor.getCaretModel().moveToOffset(toGo.getTextOffset());
       editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
     }
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithForSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithForSurrounder.java
index 1055c46..e03e6c3 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithForSurrounder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithForSurrounder.java
@@ -17,7 +17,7 @@
 package com.intellij.codeInsight.generation.surroundWith;
 
 import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
@@ -58,13 +58,13 @@
     bodyBlock.addRange(statements[0], statements[statements.length - 1]);
     container.deleteChildRange(statements[0], statements[statements.length - 1]);
 
-    forStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(forStatement);
+    forStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(forStatement);
     PsiStatement initialization = forStatement.getInitialization();
     if (initialization == null) {
       return null;
     }
     TextRange range1 = initialization.getTextRange();
-    
+
     PsiStatement update = forStatement.getUpdate();
     if (update == null) {
       return null;
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfElseExpressionSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfElseExpressionSurrounder.java
index f789f8ef..a753fc6 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfElseExpressionSurrounder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfElseExpressionSurrounder.java
@@ -17,7 +17,7 @@
 package com.intellij.codeInsight.generation.surroundWith;
 
 import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
@@ -45,8 +45,8 @@
 
     PsiCodeBlock block = ((PsiBlockStatement)ifStatement.getThenBranch()).getCodeBlock();
 
-    PsiStatement afterStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(block.getStatements()[0]);
-    
+    PsiStatement afterStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(block.getStatements()[0]);
+
     TextRange range = afterStatement.getTextRange();
     editor.getDocument().deleteString(range.getStartOffset(), range.getEndOffset());
     return new TextRange(range.getStartOffset(), range.getStartOffset());
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfElseSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfElseSurrounder.java
index 7c977e4..4ce38c1 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfElseSurrounder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfElseSurrounder.java
@@ -17,7 +17,7 @@
 package com.intellij.codeInsight.generation.surroundWith;
 
 import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
@@ -57,7 +57,7 @@
     SurroundWithUtil.indentCommentIfNecessary(thenBlock, statements);
     thenBlock.addRange(statements[0], statements[statements.length - 1]);
     container.deleteChildRange(statements[0], statements[statements.length - 1]);
-    ifStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(ifStatement);
+    ifStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(ifStatement);
     PsiExpression condition = ifStatement.getCondition();
     if (condition == null) {
       return null;
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfExpressionSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfExpressionSurrounder.java
index a52d0bb..0c492c9 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfExpressionSurrounder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfExpressionSurrounder.java
@@ -17,7 +17,7 @@
 package com.intellij.codeInsight.generation.surroundWith;
 
 import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
@@ -55,7 +55,7 @@
     ifStatement = (PsiIfStatement)statement.replace(ifStatement);
 
     PsiCodeBlock block = ((PsiBlockStatement)ifStatement.getThenBranch()).getCodeBlock();
-    block = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(block);
+    block = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(block);
     TextRange range = block.getStatements()[0].getTextRange();
     editor.getDocument().deleteString(range.getStartOffset(), range.getEndOffset());
     return new TextRange(range.getStartOffset(), range.getStartOffset());
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfSurrounder.java
index 8e8454e..01d9840 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfSurrounder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfSurrounder.java
@@ -17,7 +17,7 @@
 package com.intellij.codeInsight.generation.surroundWith;
 
 import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
@@ -57,7 +57,7 @@
       container.deleteChildRange(statements[0], statements[statements.length - 1]);
     }
 
-    ifStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(ifStatement);
+    ifStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(ifStatement);
     if (ifStatement == null) {
       return null;
     }
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNotInstanceofSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNotInstanceofSurrounder.java
index 8ea3c4d..cec501f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNotInstanceofSurrounder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNotInstanceofSurrounder.java
@@ -17,7 +17,7 @@
 package com.intellij.codeInsight.generation.surroundWith;
 
 import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
@@ -48,7 +48,7 @@
     prefixExpr = (PsiPrefixExpression)expr.replace(prefixExpr);
     parenthExpr = (PsiParenthesizedExpression)prefixExpr.getOperand();
     instanceofExpr = (PsiInstanceOfExpression)parenthExpr.getExpression();
-    instanceofExpr = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(instanceofExpr);
+    instanceofExpr = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(instanceofExpr);
     TextRange range = instanceofExpr.getCheckType().getTextRange();
     editor.getDocument().deleteString(range.getStartOffset(), range.getEndOffset());
     return new TextRange(range.getStartOffset(), range.getStartOffset());
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNullCheckSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNullCheckSurrounder.java
index 612c655..aa258ab 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNullCheckSurrounder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNullCheckSurrounder.java
@@ -16,7 +16,7 @@
  */
 package com.intellij.codeInsight.generation.surroundWith;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
@@ -56,7 +56,7 @@
     String oldText = statement.getText();
     ifStatement = (PsiIfStatement)statement.replace(ifStatement);
     PsiCodeBlock block = ((PsiBlockStatement)ifStatement.getThenBranch()).getCodeBlock();
-    block = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(block);
+    block = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(block);
     PsiElement replace = block.getStatements()[0].replace(factory.createStatementFromText(oldText, block));
     int offset = replace.getTextRange().getEndOffset();
     return new TextRange(offset, offset);
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithSynchronizedSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithSynchronizedSurrounder.java
index 1e2754c..a19980d 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithSynchronizedSurrounder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithSynchronizedSurrounder.java
@@ -17,7 +17,7 @@
 package com.intellij.codeInsight.generation.surroundWith;
 
 import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
@@ -57,7 +57,7 @@
     synchronizedBlock.addRange(statements[0], statements[statements.length - 1]);
     container.deleteChildRange(statements[0], statements[statements.length - 1]);
 
-    synchronizedStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(synchronizedStatement);
+    synchronizedStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(synchronizedStatement);
     PsiExpression lockExpression = synchronizedStatement.getLockExpression();
     if (lockExpression == null) {
       return null;
diff --git a/java/java-impl/src/com/intellij/codeInsight/guess/GuessManager.java b/java/java-impl/src/com/intellij/codeInsight/guess/GuessManager.java
deleted file mode 100644
index bda1401..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/guess/GuessManager.java
+++ /dev/null
@@ -1,43 +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.guess;
-
-import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.PsiExpression;
-import com.intellij.psi.PsiType;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Map;
-
-public abstract class GuessManager {
-  public static GuessManager getInstance(Project project) {
-    return ServiceManager.getService(project, GuessManager.class);
-  }
-
-  public abstract PsiType[] guessContainerElementType(PsiExpression containerExpr, TextRange rangeToIgnore);
-
-  public abstract PsiType[] guessTypeToCast(PsiExpression expr);
-
-  @NotNull 
-  public abstract Map<PsiExpression, PsiType> getControlFlowExpressionTypes(@NotNull PsiExpression forPlace);
-
-  @Nullable
-  public abstract PsiType getControlFlowExpressionType(@NotNull PsiExpression expr);
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/guess/impl/DfaInstanceofValue.java b/java/java-impl/src/com/intellij/codeInsight/guess/impl/DfaInstanceofValue.java
deleted file mode 100644
index 574fa5e..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/guess/impl/DfaInstanceofValue.java
+++ /dev/null
@@ -1,62 +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.guess.impl;
-
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-import com.intellij.codeInspection.dataFlow.value.DfaValueFactory;
-import com.intellij.psi.PsiExpression;
-import com.intellij.psi.PsiType;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * @author peter
- */
-public class DfaInstanceofValue extends DfaValue {
-  private final PsiExpression myExpression;
-  private final PsiType myCastType;
-  private final boolean myNegated;
-
-  public DfaInstanceofValue(DfaValueFactory factory, PsiExpression expression, PsiType castType) {
-    this(factory, expression, castType, false);
-  }
-
-  public DfaInstanceofValue(DfaValueFactory factory, PsiExpression expression, PsiType castType, boolean negated) {
-    super(factory);
-    myExpression = expression;
-    myCastType = castType;
-    myNegated = negated;
-  }
-
-  @Nullable
-  public PsiExpression getExpression() {
-    return myExpression;
-  }
-
-  @NotNull
-  public PsiType getCastType() {
-    return myCastType;
-  }
-
-  public boolean isNegated() {
-    return myNegated;
-  }
-
-  @Override
-  public DfaValue createNegated() {
-    return new DfaInstanceofValue(myFactory, myExpression, myCastType, !myNegated);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/guess/impl/ExpressionTypeMemoryState.java b/java/java-impl/src/com/intellij/codeInsight/guess/impl/ExpressionTypeMemoryState.java
deleted file mode 100644
index 9e30492..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/guess/impl/ExpressionTypeMemoryState.java
+++ /dev/null
@@ -1,116 +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.guess.impl;
-
-import com.intellij.codeInsight.CodeInsightUtil;
-import com.intellij.codeInspection.dataFlow.DfaMemoryStateImpl;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-import com.intellij.codeInspection.dataFlow.value.DfaValueFactory;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.psi.PsiExpression;
-import com.intellij.psi.PsiType;
-import com.intellij.util.containers.HashMap;
-import gnu.trove.THashMap;
-import gnu.trove.TObjectHashingStrategy;
-
-import java.util.Map;
-
-/**
- * @author peter
- */
-public class ExpressionTypeMemoryState extends DfaMemoryStateImpl {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.guess.impl.ExpressionTypeMemoryState");
-  public static final TObjectHashingStrategy<PsiExpression> EXPRESSION_HASHING_STRATEGY = new TObjectHashingStrategy<PsiExpression>() {
-    @Override
-    public int computeHashCode(PsiExpression object) {
-      return object.getNode().getElementType().hashCode();
-    }
-
-    @Override
-    public boolean equals(PsiExpression o1, PsiExpression o2) {
-      if (CodeInsightUtil.areExpressionsEquivalent(o1, o2)) {
-        if (computeHashCode(o1) != computeHashCode(o2)) {
-          LOG.error("different hashCodes: " + o1 + "; " + o2 + "; " + computeHashCode(o1) + "!=" + computeHashCode(o2));
-        }
-
-        return true;
-      }
-      return false;
-    }
-  };
-  private final Map<PsiExpression, PsiType> myStates = new THashMap<PsiExpression, PsiType>(EXPRESSION_HASHING_STRATEGY);
-
-  public ExpressionTypeMemoryState(final DfaValueFactory factory) {
-    super(factory);
-  }
-
-  @Override
-  protected DfaMemoryStateImpl createNew() {
-    return new ExpressionTypeMemoryState(getFactory());
-  }
-
-  @Override
-  public DfaMemoryStateImpl createCopy() {
-    final ExpressionTypeMemoryState copy = (ExpressionTypeMemoryState)super.createCopy();
-    copy.myStates.putAll(myStates);
-    return copy;
-  }
-
-  @Override
-  public boolean applyCondition(DfaValue dfaCond) {
-    if (dfaCond instanceof DfaInstanceofValue) {
-      final DfaInstanceofValue value = (DfaInstanceofValue)dfaCond;
-      if (!value.isNegated()) {
-        setExpressionType(value.getExpression(), value.getCastType());
-      }
-    }
-
-    return super.applyCondition(dfaCond);
-  }
-
-  public Map<PsiExpression, PsiType> getStates() {
-    return myStates;
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    if (!super.equals(o)) return false;
-
-    ExpressionTypeMemoryState that = (ExpressionTypeMemoryState)o;
-
-    if (!myStates.equals(that.myStates)) return false;
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    int result = super.hashCode();
-    result = 31 * result + myStates.hashCode();
-    return result;
-  }
-
-  @Override
-  public String toString() {
-    return super.toString() + " states=[" + new HashMap<PsiExpression, PsiType>(myStates) + "]";
-  }
-
-  public void setExpressionType(PsiExpression expression, PsiType type) {
-    myStates.put(expression, type);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/guess/impl/GuessManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/guess/impl/GuessManagerImpl.java
deleted file mode 100644
index c6716c3..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/guess/impl/GuessManagerImpl.java
+++ /dev/null
@@ -1,449 +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.guess.impl;
-
-import com.intellij.codeInsight.guess.GuessManager;
-import com.intellij.codeInspection.dataFlow.*;
-import com.intellij.codeInspection.dataFlow.instructions.PushInstruction;
-import com.intellij.codeInspection.dataFlow.instructions.TypeCastInstruction;
-import com.intellij.codeInspection.dataFlow.instructions.InstanceofInstruction;
-import com.intellij.codeInspection.dataFlow.instructions.MethodCallInstruction;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.*;
-import com.intellij.psi.search.LocalSearchScope;
-import com.intellij.psi.search.PsiElementProcessor;
-import com.intellij.psi.search.PsiElementProcessorAdapter;
-import com.intellij.psi.search.SearchScope;
-import com.intellij.psi.search.searches.ClassInheritorsSearch;
-import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.containers.ContainerUtil;
-import gnu.trove.THashMap;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.*;
-
-public class GuessManagerImpl extends GuessManager {
-
-  private final MethodPatternMap myMethodPatternMap = new MethodPatternMap();
-
-  {
-    initMethodPatterns();
-  }
-
-  @SuppressWarnings({"HardCodedStringLiteral"})
-  private void initMethodPatterns() {
-    // Collection
-    myMethodPatternMap.addPattern(new MethodPattern("add", 1, 0));
-    myMethodPatternMap.addPattern(new MethodPattern("contains", 1, 0));
-    myMethodPatternMap.addPattern(new MethodPattern("remove", 1, 0));
-
-    // Vector
-    myMethodPatternMap.addPattern(new MethodPattern("add", 2, 1));
-    myMethodPatternMap.addPattern(new MethodPattern("addElement", 1, 0));
-    myMethodPatternMap.addPattern(new MethodPattern("elementAt", 1, -1));
-    myMethodPatternMap.addPattern(new MethodPattern("firstElement", 0, -1));
-    myMethodPatternMap.addPattern(new MethodPattern("lastElement", 0, -1));
-    myMethodPatternMap.addPattern(new MethodPattern("get", 1, -1));
-    myMethodPatternMap.addPattern(new MethodPattern("indexOf", 1, 0));
-    myMethodPatternMap.addPattern(new MethodPattern("indexOf", 2, 0));
-    myMethodPatternMap.addPattern(new MethodPattern("lastIndexOf", 1, 0));
-    myMethodPatternMap.addPattern(new MethodPattern("lastIndexOf", 2, 0));
-    myMethodPatternMap.addPattern(new MethodPattern("insertElementAt", 2, 0));
-    myMethodPatternMap.addPattern(new MethodPattern("removeElement", 1, 0));
-    myMethodPatternMap.addPattern(new MethodPattern("set", 2, 1));
-    myMethodPatternMap.addPattern(new MethodPattern("setElementAt", 2, 0));
-  }
-
-  private final Project myProject;
-
-  public GuessManagerImpl(Project project) {
-    myProject = project;
-  }
-
-  @Override
-  public PsiType[] guessContainerElementType(PsiExpression containerExpr, TextRange rangeToIgnore) {
-    HashSet<PsiType> typesSet = new HashSet<PsiType>();
-
-    PsiType type = containerExpr.getType();
-    PsiType elemType;
-    if ((elemType = getGenericElementType(type)) != null) return new PsiType[]{elemType};
-
-    if (containerExpr instanceof PsiReferenceExpression){
-      PsiElement refElement = ((PsiReferenceExpression)containerExpr).resolve();
-      if (refElement instanceof PsiVariable){
-
-        PsiFile file = refElement.getContainingFile();
-        if (file == null){
-          file = containerExpr.getContainingFile(); // implicit variable in jsp
-        }
-        HashSet<PsiVariable> checkedVariables = new HashSet<PsiVariable>();
-        addTypesByVariable(typesSet, (PsiVariable)refElement, file, checkedVariables, CHECK_USAGE | CHECK_DOWN, rangeToIgnore);
-        checkedVariables.clear();
-        addTypesByVariable(typesSet, (PsiVariable)refElement, file, checkedVariables, CHECK_UP, rangeToIgnore);
-      }
-    }
-
-    return typesSet.toArray(new PsiType[typesSet.size()]);
-  }
-
-  @Nullable
-  private static PsiType getGenericElementType(PsiType collectionType) {
-    if (collectionType instanceof PsiClassType) {
-      PsiClassType classType = (PsiClassType) collectionType;
-      PsiType[] parameters = classType.getParameters();
-      if (parameters.length == 1) {
-        return parameters[0];
-      }
-    }
-    return null;
-  }
-
-  @Override
-  public PsiType[] guessTypeToCast(PsiExpression expr) { //TODO : make better guess based on control flow
-    LinkedHashSet<PsiType> types = new LinkedHashSet<PsiType>();
-
-    ContainerUtil.addIfNotNull(getControlFlowExpressionType(expr), types);
-    addExprTypesWhenContainerElement(types, expr);
-    addExprTypesByDerivedClasses(types, expr);
-
-    return types.toArray(new PsiType[types.size()]);
-  }
-
-  @NotNull
-  @Override
-  public Map<PsiExpression, PsiType> getControlFlowExpressionTypes(@NotNull final PsiExpression forPlace) {
-    final Map<PsiExpression, PsiType> typeMap = buildDataflowTypeMap(forPlace);
-    if (typeMap != null) {
-      return typeMap;
-    }
-
-    return Collections.emptyMap();
-  }
-
-  @Nullable
-  private static Map<PsiExpression, PsiType> buildDataflowTypeMap(PsiExpression forPlace) {
-    PsiElement scope = DfaUtil.getTopmostBlockInSameClass(forPlace);
-    if (scope == null) {
-      PsiFile file = forPlace.getContainingFile();
-      if (!(file instanceof PsiCodeFragment)) {
-        return Collections.emptyMap();
-      }
-
-      scope = file;
-    }
-
-    DataFlowRunner runner = new DataFlowRunner() {
-      @Override
-      protected DfaMemoryState createMemoryState() {
-        return new ExpressionTypeMemoryState(getFactory());
-      }
-    };
-
-    final ExpressionTypeInstructionVisitor visitor = new ExpressionTypeInstructionVisitor(forPlace);
-    if (runner.analyzeMethod(scope, visitor) == RunnerResult.OK) {
-      return visitor.getResult();
-    }
-    return null;
-  }
-
-  private static Map<PsiExpression, PsiType> getAllTypeCasts(PsiExpression forPlace) {
-    assert forPlace.isValid();
-    final int start = forPlace.getTextRange().getStartOffset();
-    final Map<PsiExpression, PsiType> allCasts = new THashMap<PsiExpression, PsiType>(ExpressionTypeMemoryState.EXPRESSION_HASHING_STRATEGY);
-    getTopmostBlock(forPlace).accept(new JavaRecursiveElementWalkingVisitor() {
-      @Override
-      public void visitTypeCastExpression(PsiTypeCastExpression expression) {
-        final PsiType castType = expression.getType();
-        final PsiExpression operand = expression.getOperand();
-        if (operand != null && castType != null) {
-          allCasts.put(operand, castType);
-        }
-        super.visitTypeCastExpression(expression);
-      }
-
-      @Override
-      public void visitInstanceOfExpression(PsiInstanceOfExpression expression) {
-        final PsiTypeElement castType = expression.getCheckType();
-        final PsiExpression operand = expression.getOperand();
-        if (castType != null) {
-          allCasts.put(operand, castType.getType());
-        }
-        super.visitInstanceOfExpression(expression);
-      }
-
-      @Override
-      public void visitElement(PsiElement element) {
-        if (element.getTextRange().getStartOffset() > start) {
-          return;
-        }
-
-        super.visitElement(element);
-      }
-    });
-    return allCasts;
-  }
-
-  private static PsiElement getTopmostBlock(PsiElement scope) {
-    assert scope.isValid();
-    PsiElement lastScope = scope;
-    while (true) {
-      final PsiCodeBlock lastCodeBlock = PsiTreeUtil.getParentOfType(lastScope, PsiCodeBlock.class, true);
-      if (lastCodeBlock == null) {
-        break;
-      }
-      lastScope = lastCodeBlock;
-    }
-    if (lastScope == scope) {
-      PsiFile file = scope.getContainingFile();
-      if (file instanceof PsiCodeFragment) {
-        return file;
-      }
-    }
-    return lastScope;
-  }
-
-  private void addExprTypesByDerivedClasses(LinkedHashSet<PsiType> set, PsiExpression expr) {
-    PsiType type = expr.getType();
-    if (!(type instanceof PsiClassType)) return;
-    PsiClass refClass = PsiUtil.resolveClassInType(type);
-    if (refClass == null) return;
-
-    PsiManager manager = PsiManager.getInstance(myProject);
-    PsiElementProcessor.CollectElementsWithLimit<PsiClass> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiClass>(5);
-    ClassInheritorsSearch.search(refClass, true).forEach(new PsiElementProcessorAdapter<PsiClass>(processor));
-    if (processor.isOverflow()) return;
-
-    for (PsiClass derivedClass : processor.getCollection()) {
-      if (derivedClass instanceof PsiAnonymousClass) continue;
-      PsiType derivedType = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(derivedClass);
-      set.add(derivedType);
-    }
-  }
-
-  private void addExprTypesWhenContainerElement(LinkedHashSet<PsiType> set, PsiExpression expr) {
-    if (expr instanceof PsiMethodCallExpression){
-      PsiMethodCallExpression callExpr = (PsiMethodCallExpression)expr;
-      PsiReferenceExpression methodExpr = callExpr.getMethodExpression();
-      String methodName = methodExpr.getReferenceName();
-      MethodPattern pattern = myMethodPatternMap.findPattern(methodName, callExpr.getArgumentList().getExpressions().length);
-      if (pattern != null && pattern.parameterIndex < 0/* return value */){
-        PsiExpression qualifier = methodExpr.getQualifierExpression();
-        if (qualifier != null) {
-          PsiType[] types = guessContainerElementType(qualifier, null);
-          for (PsiType type : types) {
-            if (type instanceof PsiClassType) {
-              if (((PsiClassType)type).resolve() instanceof PsiAnonymousClass) continue;
-            }
-            set.add(type);
-          }
-        }
-      }
-    }
-  }
-
-  private static final int CHECK_USAGE = 0x01;
-  private static final int CHECK_UP = 0x02;
-  private static final int CHECK_DOWN = 0x04;
-
-  private void addTypesByVariable(HashSet<PsiType> typesSet,
-                                  PsiVariable var,
-                                  PsiFile scopeFile,
-                                  HashSet<PsiVariable> checkedVariables,
-                                  int flags,
-                                  TextRange rangeToIgnore) {
-    if (!checkedVariables.add(var)) return;
-    //System.out.println("analyzing usages of " + var + " in file " + scopeFile);
-    SearchScope searchScope = new LocalSearchScope(scopeFile);
-
-    if ((flags & (CHECK_USAGE | CHECK_DOWN)) != 0){
-      for (PsiReference varRef : ReferencesSearch.search(var, searchScope, false)) {
-        PsiElement ref = varRef.getElement();
-
-        if ((flags & CHECK_USAGE) != 0) {
-          PsiType type = guessElementTypeFromReference(myMethodPatternMap, ref, rangeToIgnore);
-          if (type != null && !(type instanceof PsiPrimitiveType)) {
-            typesSet.add(type);
-          }
-        }
-
-        if ((flags & CHECK_DOWN) != 0) {
-          if (ref.getParent() instanceof PsiExpressionList && ref.getParent().getParent() instanceof PsiMethodCallExpression) { //TODO : new
-            PsiExpressionList list = (PsiExpressionList)ref.getParent();
-            PsiExpression[] args = list.getExpressions();
-            int argIndex = -1;
-            for (int j = 0; j < args.length; j++) {
-              PsiExpression arg = args[j];
-              if (arg.equals(ref)) {
-                argIndex = j;
-                break;
-              }
-            }
-
-            PsiMethodCallExpression methodCall = (PsiMethodCallExpression)list.getParent();
-            PsiMethod method = (PsiMethod)methodCall.getMethodExpression().resolve();
-            if (method != null) {
-              PsiParameter[] parameters = method.getParameterList().getParameters();
-              if (argIndex < parameters.length) {
-                addTypesByVariable(typesSet, parameters[argIndex], method.getContainingFile(), checkedVariables, flags | CHECK_USAGE,
-                                   rangeToIgnore);
-              }
-            }
-          }
-        }
-      }
-    }
-
-    if ((flags & CHECK_UP) != 0){
-      if (var instanceof PsiParameter && var.getParent() instanceof PsiParameterList && var.getParent().getParent() instanceof PsiMethod){
-        PsiParameterList list = (PsiParameterList)var.getParent();
-        PsiParameter[] parameters = list.getParameters();
-        int argIndex = -1;
-        for(int i = 0; i < parameters.length; i++){
-          PsiParameter parameter = parameters[i];
-          if (parameter.equals(var)){
-            argIndex = i;
-            break;
-          }
-        }
-
-        PsiMethod method = (PsiMethod)var.getParent().getParent();
-        //System.out.println("analyzing usages of " + method + " in file " + scopeFile);
-        for (PsiReference methodRef : ReferencesSearch.search(method, searchScope, false)) {
-          PsiElement ref = methodRef.getElement();
-          if (ref.getParent() instanceof PsiMethodCallExpression) {
-            PsiMethodCallExpression methodCall = (PsiMethodCallExpression)ref.getParent();
-            PsiExpression[] args = methodCall.getArgumentList().getExpressions();
-            if (args.length <= argIndex) continue;
-            PsiExpression arg = args[argIndex];
-            if (arg instanceof PsiReferenceExpression) {
-              PsiElement refElement = ((PsiReferenceExpression)arg).resolve();
-              if (refElement instanceof PsiVariable) {
-                addTypesByVariable(typesSet, (PsiVariable)refElement, scopeFile, checkedVariables, flags | CHECK_USAGE, rangeToIgnore);
-              }
-            }
-            //TODO : constructor
-          }
-        }
-      }
-    }
-  }
-
-  @Nullable
-  private static PsiType guessElementTypeFromReference(MethodPatternMap methodPatternMap,
-                                                       PsiElement ref,
-                                                       TextRange rangeToIgnore) {
-    PsiElement refParent = ref.getParent();
-    if (refParent instanceof PsiReferenceExpression){
-      PsiReferenceExpression parentExpr = (PsiReferenceExpression)refParent;
-      if (ref.equals(parentExpr.getQualifierExpression()) && parentExpr.getParent() instanceof PsiMethodCallExpression){
-        String methodName = parentExpr.getReferenceName();
-        PsiMethodCallExpression methodCall = (PsiMethodCallExpression)parentExpr.getParent();
-        PsiExpression[] args = methodCall.getArgumentList().getExpressions();
-        MethodPattern pattern = methodPatternMap.findPattern(methodName, args.length);
-        if (pattern != null){
-          if (pattern.parameterIndex < 0){ // return value
-            if (methodCall.getParent() instanceof PsiTypeCastExpression &&
-                (rangeToIgnore == null || !rangeToIgnore.contains(methodCall.getTextRange()))) {
-              return ((PsiTypeCastExpression)methodCall.getParent()).getType();
-            }
-          }
-          else{
-            return args[pattern.parameterIndex].getType();
-          }
-        }
-      }
-    }
-    return null;
-  }
-
-  @Override
-  @Nullable
-  public PsiType getControlFlowExpressionType(@NotNull PsiExpression expr) {
-    final Map<PsiExpression, PsiType> allCasts = getAllTypeCasts(expr);
-    if (!allCasts.containsKey(expr)) {
-      return null; //optimization
-    }
-
-    final Map<PsiExpression, PsiType> fromDfa = buildDataflowTypeMap(expr);
-    if (fromDfa != null) {
-      return fromDfa.get(expr);
-    }
-
-    return null;
-  }
-
-  private static class ExpressionTypeInstructionVisitor extends InstructionVisitor {
-    private Map<PsiExpression, PsiType> myResult;
-    private final PsiElement myForPlace;
-
-    private ExpressionTypeInstructionVisitor(PsiElement forPlace) {
-      myForPlace = forPlace;
-    }
-
-    public Map<PsiExpression, PsiType> getResult() {
-      return myResult;
-    }
-
-    @Override
-    public DfaInstructionState[] visitInstanceof(InstanceofInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-      memState.pop();
-      memState.pop();
-      memState.push(new DfaInstanceofValue(runner.getFactory(), instruction.getLeft(), instruction.getCastType()));
-      return new DfaInstructionState[]{new DfaInstructionState(runner.getInstruction(instruction.getIndex() + 1), memState)};
-    }
-
-    @Override
-    public DfaInstructionState[] visitTypeCast(TypeCastInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-      ((ExpressionTypeMemoryState) memState).setExpressionType(instruction.getCasted(), instruction.getCastTo());
-      return super.visitTypeCast(instruction, runner, memState);
-    }
-
-    @Override
-    public DfaInstructionState[] visitMethodCall(MethodCallInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-      if (myForPlace == instruction.getCallExpression()) {
-        addToResult(((ExpressionTypeMemoryState)memState).getStates());
-      }
-      return super.visitMethodCall(instruction, runner, memState);
-    }
-
-    @Override
-    public DfaInstructionState[] visitPush(PushInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-      if (myForPlace == instruction.getPlace()) {
-        addToResult(((ExpressionTypeMemoryState)memState).getStates());
-      }
-      return super.visitPush(instruction, runner, memState);
-    }
-
-    private void addToResult(Map<PsiExpression, PsiType> map) {
-      if (myResult == null) {
-        myResult = new THashMap<PsiExpression, PsiType>(map, ExpressionTypeMemoryState.EXPRESSION_HASHING_STRATEGY);
-      } else {
-        final Iterator<PsiExpression> iterator = myResult.keySet().iterator();
-        while (iterator.hasNext()) {
-          PsiExpression psiExpression = iterator.next();
-          if (!myResult.get(psiExpression).equals(map.get(psiExpression))) {
-            iterator.remove();
-          }
-        }
-      }
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/guess/impl/MethodPattern.java b/java/java-impl/src/com/intellij/codeInsight/guess/impl/MethodPattern.java
deleted file mode 100644
index 07ea6a2..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/guess/impl/MethodPattern.java
+++ /dev/null
@@ -1,29 +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.guess.impl;
-
-class MethodPattern{
-  public final String methodName;
-  public final int parameterCount;
-  public final int parameterIndex; // -1 for return type
-
-  public MethodPattern(String methodName, int parameterCount, int parameterIndex) {
-    this.methodName = methodName;
-    this.parameterCount = parameterCount;
-    this.parameterIndex = parameterIndex;
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/guess/impl/MethodPatternMap.java b/java/java-impl/src/com/intellij/codeInsight/guess/impl/MethodPatternMap.java
deleted file mode 100644
index 946d6e8..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/guess/impl/MethodPatternMap.java
+++ /dev/null
@@ -1,31 +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.guess.impl;
-
-import com.intellij.util.containers.HashMap;
-
-class MethodPatternMap {
-  private final HashMap myMethodNameToPatternsMap = new HashMap();
-
-  public void addPattern(MethodPattern pattern){
-    myMethodNameToPatternsMap.put(pattern.methodName + "#" + pattern.parameterCount, pattern);
-  }
-
-  public MethodPattern findPattern(String name, int parameterCount){
-    return (MethodPattern)myMethodNameToPatternsMap.get(name + "#" + parameterCount);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/hint/actions/ShowSiblingsAction.java b/java/java-impl/src/com/intellij/codeInsight/hint/actions/ShowSiblingsAction.java
new file mode 100644
index 0000000..8a8bc91
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInsight/hint/actions/ShowSiblingsAction.java
@@ -0,0 +1,114 @@
+/*
+ * 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.hint.actions;
+
+import com.intellij.codeInsight.TargetElementUtilBase;
+import com.intellij.codeInsight.daemon.impl.PsiElementListNavigator;
+import com.intellij.codeInsight.documentation.DocumentationManager;
+import com.intellij.ide.util.MethodCellRenderer;
+import com.intellij.ide.util.PsiClassListCellRenderer;
+import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.fileEditor.FileEditor;
+import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.fileEditor.TextEditor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.popup.JBPopup;
+import com.intellij.psi.*;
+import com.intellij.psi.impl.FindSuperElementsHelper;
+import com.intellij.psi.presentation.java.SymbolPresentationUtil;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.Consumer;
+import org.jetbrains.annotations.Nullable;
+
+public class ShowSiblingsAction extends ShowImplementationsAction {
+  private static final Logger LOG = Logger.getInstance("#" + ShowSiblingsAction.class.getName());
+
+  public ShowSiblingsAction() {
+    super();
+  }
+
+  @Override
+  public void performForContext(DataContext dataContext, final boolean invokedByShortcut) {
+    final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+    final PsiFile file = LangDataKeys.PSI_FILE.getData(dataContext);
+
+    if (project == null) return;
+
+    PsiDocumentManager.getInstance(project).commitAllDocuments();
+    final Editor editor = getEditor(dataContext);
+
+    PsiElement element = getElement(project, file, editor, LangDataKeys.PSI_ELEMENT.getData(dataContext));
+
+    if (element == null && file == null) return;
+    PsiFile containingFile = element != null ? element.getContainingFile() : file;
+    if (containingFile == null || !containingFile.getViewProvider().isPhysical()) return;
+
+
+    if (editor != null) {
+      PsiReference ref = TargetElementUtilBase.findReference(editor, editor.getCaretModel().getOffset());
+      if (element == null && ref != null) {
+        element = TargetElementUtilBase.getInstance().adjustReference(ref);
+      }
+    }
+
+    final NavigatablePsiElement[] superElements = (NavigatablePsiElement[])findSuperElements(element);
+    if (superElements == null || superElements.length == 0) return;
+
+    final boolean isMethod = superElements[0] instanceof PsiMethod;
+    final JBPopup popup = PsiElementListNavigator.navigateOrCreatePopup(superElements, "Choose super " + (isMethod ? "method" : "class or interface"), "Super " + (isMethod ? "methods" : "classes/interfaces"),
+                                                                       isMethod ? new MethodCellRenderer(false) : new PsiClassListCellRenderer(), null, new Consumer<Object[]>() {
+      @Override
+      public void consume(Object[] objects) {
+        showSiblings(invokedByShortcut, project, editor, file, editor != null, (PsiElement)objects[0]);
+      }
+    });
+    if (popup != null) {
+      if (editor != null) {
+        popup.showInBestPositionFor(editor);
+      } else {
+        popup.showCenteredInCurrentWindow(project);
+      }
+    }
+  }
+
+  private void showSiblings(boolean invokedByShortcut,
+                            Project project,
+                            Editor editor,
+                            PsiFile file,
+                            boolean invokedFromEditor,
+                            PsiElement element) {
+    final PsiElement[] impls = getSelfAndImplementations(editor, element, createImplementationsSearcher(), false);
+    final String text = SymbolPresentationUtil.getSymbolPresentableText(element);
+    showImplementations(impls, project, text, editor, file, element, invokedFromEditor, invokedByShortcut);
+  }
+
+  @Override
+  protected boolean isIncludeAlwaysSelf() {
+    return false;
+  }
+
+  @Nullable
+  private static PsiElement[] findSuperElements(final PsiElement element) {
+    PsiNameIdentifierOwner parent = PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiClass.class);
+    if (parent == null) {
+      return null;
+    }
+
+    return FindSuperElementsHelper.findSuperElements(parent);
+  }
+}
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNotNullAnnotationFix.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNotNullAnnotationFix.java
deleted file mode 100644
index dd04cd1..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNotNullAnnotationFix.java
+++ /dev/null
@@ -1,44 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: cdr
- * Date: Jul 20, 2007
- * Time: 2:57:38 PM
- */
-package com.intellij.codeInsight.intention.impl;
-
-import com.intellij.codeInsight.NullableNotNullManager;
-import com.intellij.psi.PsiModifierListOwner;
-import com.intellij.util.ArrayUtil;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.List;
-
-public class AddNotNullAnnotationFix extends AddNullableNotNullAnnotationFix {
-  public AddNotNullAnnotationFix(@NotNull PsiModifierListOwner owner) {
-    super(NullableNotNullManager.getInstance(owner.getProject()).getDefaultNotNull(),
-          owner,
-          getNullables(owner));
-  }
-
-  @NotNull
-  private static String[] getNullables(@NotNull PsiModifierListOwner owner) {
-    final List<String> nullables = NullableNotNullManager.getInstance(owner.getProject()).getNullables();
-    return ArrayUtil.toStringArray(nullables);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNullableAnnotationFix.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNullableAnnotationFix.java
deleted file mode 100644
index 9d6a4f1..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNullableAnnotationFix.java
+++ /dev/null
@@ -1,44 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: cdr
- * Date: Jul 20, 2007
- * Time: 2:57:59 PM
- */
-package com.intellij.codeInsight.intention.impl;
-
-import com.intellij.codeInsight.NullableNotNullManager;
-import com.intellij.psi.PsiModifierListOwner;
-import com.intellij.util.ArrayUtil;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.List;
-
-public class AddNullableAnnotationFix extends AddNullableNotNullAnnotationFix {
-  public AddNullableAnnotationFix(@NotNull PsiModifierListOwner owner) {
-    super(NullableNotNullManager.getInstance(owner.getProject()).getDefaultNullable(),
-          owner,
-          getNotNulls(owner));
-  }
-
-  @NotNull
-  private static String[] getNotNulls(@NotNull PsiModifierListOwner owner) {
-    final List<String> notnulls = NullableNotNullManager.getInstance(owner.getProject()).getNotNulls();
-    return ArrayUtil.toStringArray(notnulls);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNullableNotNullAnnotationFix.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNullableNotNullAnnotationFix.java
deleted file mode 100644
index 8ab713b..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddNullableNotNullAnnotationFix.java
+++ /dev/null
@@ -1,55 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: cdr
- * Date: Jul 20, 2007
- * Time: 2:57:59 PM
- */
-package com.intellij.codeInsight.intention.impl;
-
-import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.codeInsight.intention.AddAnnotationFix;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import org.jetbrains.annotations.NotNull;
-
-public class AddNullableNotNullAnnotationFix extends AddAnnotationFix {
-  public AddNullableNotNullAnnotationFix(@NotNull String fqn, @NotNull PsiModifierListOwner owner, @NotNull String... annotationToRemove) {
-    super(fqn, owner, annotationToRemove);
-  }
-
-  @Override
-  public boolean isAvailable(@NotNull Project project,
-                             @NotNull PsiFile file,
-                             @NotNull PsiElement startElement,
-                             @NotNull PsiElement endElement) {
-     if (!super.isAvailable(project, file, startElement, endElement)) {
-      return false;
-    }
-    PsiModifierListOwner owner = getContainer(startElement);
-    if (owner == null || AnnotationUtil.isAnnotated(owner, getAnnotationsToRemove()[0], false, false)) {
-      return false;
-    }
-    if (owner instanceof PsiMethod) {
-      PsiType returnType = ((PsiMethod)owner).getReturnType();
-
-      return returnType != null && !(returnType instanceof PsiPrimitiveType);
-    }
-    return true;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConvertAbsolutePathToRelativeIntentionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConvertAbsolutePathToRelativeIntentionAction.java
index 3cb7547..63df5bf 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConvertAbsolutePathToRelativeIntentionAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConvertAbsolutePathToRelativeIntentionAction.java
@@ -24,6 +24,7 @@
 import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference;
 import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceOwner;
 import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet;
+import com.intellij.psi.impl.source.resolve.reference.impl.providers.PsiFileReference;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -64,9 +65,9 @@
       }
     }
     else if (original instanceof FileReferenceOwner) {
-      final FileReference fileReference = ((FileReferenceOwner)original).getLastFileReference();
-      if (fileReference != null) {
-        return fileReference;
+      final PsiFileReference fileReference = ((FileReferenceOwner)original).getLastFileReference();
+      if (fileReference instanceof FileReference) {
+        return (FileReference)fileReference;
       }
     }
 
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/SimplifyBooleanExpressionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/SimplifyBooleanExpressionAction.java
index 8b98816..3ae3ddc 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/SimplifyBooleanExpressionAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/SimplifyBooleanExpressionAction.java
@@ -39,7 +39,7 @@
   @Override
   @NotNull
   public String getFamilyName() {
-    return new SimplifyBooleanExpressionFix(null,null).getFamilyName();
+    return SimplifyBooleanExpressionFix.FAMILY_NAME;
   }
 
   @Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java
index 124636c..c55a21b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java
@@ -21,6 +21,7 @@
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInsight.intention.QuickFixFactory;
 import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
+import com.intellij.codeInspection.LocalQuickFixOnPsiElement;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PropertyMemberType;
 import com.intellij.psi.util.ClassKind;
@@ -77,10 +78,10 @@
   }
 
   @Override
-  public LocalQuickFixAndIntentionActionOnPsiElement createMethodThrowsFix(@NotNull PsiMethod method,
-                                                                           @NotNull PsiClassType exceptionClass,
-                                                                           boolean shouldThrow,
-                                                                           boolean showContainingClass) {
+  public LocalQuickFixOnPsiElement createMethodThrowsFix(@NotNull PsiMethod method,
+                                                         @NotNull PsiClassType exceptionClass,
+                                                         boolean shouldThrow,
+                                                         boolean showContainingClass) {
     return new MethodThrowsFix(method, exceptionClass, shouldThrow, showContainingClass);
   }
 
diff --git a/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java b/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java
index e93cd0d..9e89d7a 100644
--- a/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java
+++ b/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.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.
@@ -225,7 +225,7 @@
           if (!psiClass.getManager().areElementsEquivalent(resolved, psiClass) && !PsiUtil.isInnerClass(psiClass)) {
             // inner class name should be shown qualified if its not accessible by single name
             PsiClass aClass = psiClass.getContainingClass();
-            while (aClass != null && !PsiUtil.isInnerClass(aClass)) {
+            while (aClass != null && !PsiUtil.isInnerClass(aClass) && aClass.getName() != null) {
               name = aClass.getName() + '.' + name;
               allStrings.add(name);
               aClass = aClass.getContainingClass();
@@ -275,6 +275,9 @@
 
       presentation.setItemText(((PsiType)object).getCanonicalText());
       presentation.setItemTextBold(getAttribute(LookupItem.HIGHLIGHTED_ATTR) != null || object instanceof PsiPrimitiveType);
+      if (isAddArrayInitializer()) {
+        presentation.setTailText("{...}");
+      }
 
     }
     if (myBracketsCount > 0) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaArrayInitializerUnwrapper.java b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaArrayInitializerUnwrapper.java
new file mode 100644
index 0000000..59dec48
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaArrayInitializerUnwrapper.java
@@ -0,0 +1,50 @@
+/*
+ * 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.unwrap;
+
+import com.intellij.codeInsight.CodeInsightBundle;
+import com.intellij.psi.PsiArrayInitializerExpression;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiNewExpression;
+import com.intellij.psi.PsiVariable;
+import com.intellij.util.IncorrectOperationException;
+
+public class JavaArrayInitializerUnwrapper extends JavaUnwrapper {
+
+  public JavaArrayInitializerUnwrapper() {
+    super(CodeInsightBundle.message("unwrap.array.initializer"));
+  }
+
+  @Override
+  public boolean isApplicableTo(PsiElement e) {
+    if (e instanceof PsiArrayInitializerExpression) {
+      final PsiElement gParent = e.getParent();
+      if (gParent instanceof PsiNewExpression && gParent.getParent() instanceof PsiVariable) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+  @Override
+  protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
+    final PsiArrayInitializerExpression arrayInitializerExpression = (PsiArrayInitializerExpression)element;
+    final PsiElement newExpression = arrayInitializerExpression.getParent();
+    context.extractElement(arrayInitializerExpression, newExpression);
+    context.deleteExactly(newExpression);
+  }
+}
diff --git a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java
index e69505e..deda060 100644
--- a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java
@@ -22,6 +22,7 @@
   @Override
   protected Unwrapper[] createUnwrappers() {
     return new Unwrapper[]{
+      new JavaArrayInitializerUnwrapper(),
       new JavaMethodParameterUnwrapper(),
       new JavaElseUnwrapper(),
       new JavaElseRemover(),
diff --git a/java/java-impl/src/com/intellij/codeInspection/AddAssertStatementFix.java b/java/java-impl/src/com/intellij/codeInspection/AddAssertStatementFix.java
deleted file mode 100644
index d57631f..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/AddAssertStatementFix.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection;
-
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.openapi.diagnostic.Logger;
-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.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-
-/**
- * @author ven
- */
-public class AddAssertStatementFix implements LocalQuickFix {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.AddAssertStatementFix");
-  private final SmartPsiElementPointer<PsiExpression> myExpressionToAssert;
-  private final String myText;
-
-  public AddAssertStatementFix(@NotNull PsiExpression expressionToAssert) {
-    myExpressionToAssert = SmartPointerManager.getInstance(expressionToAssert.getProject()).createSmartPsiElementPointer(expressionToAssert);
-    LOG.assertTrue(PsiType.BOOLEAN.equals(expressionToAssert.getType()));
-    myText = expressionToAssert.getText();
-  }
-
-  @Override
-  @NotNull
-  public String getName() {
-    return InspectionsBundle.message("inspection.assert.quickfix", myText);
-  }
-
-  @Override
-  public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-    PsiExpression expressionToAssert = myExpressionToAssert.getElement();
-    if (expressionToAssert == null) return;
-    if (!FileModificationService.getInstance().preparePsiElementForWrite(descriptor.getPsiElement())) return;
-    PsiElement element = descriptor.getPsiElement();
-    PsiElement anchorElement = PsiTreeUtil.getParentOfType(element, PsiStatement.class);
-    LOG.assertTrue(anchorElement != null);
-    PsiElement prev = PsiTreeUtil.skipSiblingsBackward(anchorElement, PsiWhiteSpace.class);
-    if (prev instanceof PsiComment && SuppressManager.getInstance().getSuppressedInspectionIdsIn(prev) != null) {
-      anchorElement = prev;
-    }
-
-    try {
-      final PsiElementFactory factory = JavaPsiFacade.getInstance(element.getProject()).getElementFactory();
-      @NonNls String text = "assert c;";
-      PsiAssertStatement assertStatement = (PsiAssertStatement)factory.createStatementFromText(text, null);
-      final PsiExpression assertCondition = assertStatement.getAssertCondition();
-      assert assertCondition != null;
-
-      assertCondition.replace(expressionToAssert);
-      final PsiElement parent = anchorElement.getParent();
-      if (parent instanceof PsiCodeBlock) {
-        parent.addBefore(assertStatement, anchorElement);
-      }
-      else {
-        PsiBlockStatement blockStatement = (PsiBlockStatement)factory.createStatementFromText("{}", null);
-        final PsiCodeBlock block = blockStatement.getCodeBlock();
-        block.add(assertStatement);
-        block.add(anchorElement);
-        anchorElement.replace(blockStatement);
-      }
-    }
-    catch (IncorrectOperationException e) {
-      LOG.error(e);
-    }
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return InspectionsBundle.message("inspection.quickfix.assert.family");
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/AnnotateMethodFix.java b/java/java-impl/src/com/intellij/codeInspection/AnnotateMethodFix.java
deleted file mode 100644
index 45e8c7b..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/AnnotateMethodFix.java
+++ /dev/null
@@ -1,123 +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.codeInspection;
-
-import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.intention.AddAnnotationFix;
-import com.intellij.openapi.command.undo.UndoUtil;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiModifier;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.search.searches.OverridingMethodsSearch;
-import com.intellij.psi.util.ClassUtil;
-import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.usageView.UsageViewUtil;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author cdr
- */
-public class AnnotateMethodFix implements LocalQuickFix {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.AnnotateMethodFix");
-  protected final String myAnnotation;
-  private final String[] myAnnotationsToRemove;
-
-  public AnnotateMethodFix(final String fqn, String... annotationsToRemove) {
-    myAnnotation = fqn;
-    myAnnotationsToRemove = annotationsToRemove;
-  }
-
-  @Override
-  @NotNull
-  public String getName() {
-    return InspectionsBundle.message("inspection.annotate.method.quickfix.name", ClassUtil.extractClassName(myAnnotation));
-  }
-
-  @Override
-  public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-    final PsiElement psiElement = descriptor.getPsiElement();
-
-    PsiMethod method = PsiTreeUtil.getParentOfType(psiElement, PsiMethod.class);
-    if (method == null) return;
-    final List<PsiMethod> toAnnotate = new ArrayList<PsiMethod>();
-    toAnnotate.add(method);
-    List<MethodSignatureBackedByPsiMethod> superMethodSignatures = method.findSuperMethodSignaturesIncludingStatic(true);
-    for (MethodSignatureBackedByPsiMethod superMethodSignature : superMethodSignatures) {
-      PsiMethod superMethod = superMethodSignature.getMethod();
-      if (!AnnotationUtil.isAnnotated(superMethod, myAnnotation, false, false) && superMethod.getManager().isInProject(superMethod)) {
-        int ret = annotateBaseMethod(method, superMethod, project);
-        if (ret != 0 && ret != 1) return;
-        if (ret == 0) {
-          toAnnotate.add(superMethod);
-        }
-      }
-    }
-    if (annotateOverriddenMethods()) {
-      PsiMethod[] methods = OverridingMethodsSearch.search(method, GlobalSearchScope.allScope(project), true).toArray(PsiMethod.EMPTY_ARRAY);
-      for (PsiMethod psiMethod : methods) {
-        if (AnnotationUtil.isAnnotatingApplicable(psiMethod, myAnnotation) && !AnnotationUtil.isAnnotated(psiMethod, myAnnotation, false, false) && psiMethod.getManager().isInProject(psiMethod)) {
-          toAnnotate.add(psiMethod);
-        }
-      }
-    }
-
-    FileModificationService.getInstance().preparePsiElementsForWrite(toAnnotate);
-    for (PsiMethod psiMethod : toAnnotate) {
-      annotateMethod(psiMethod);
-    }
-    UndoUtil.markPsiFileForUndo(method.getContainingFile());
-  }
-
-  public int annotateBaseMethod(final PsiMethod method, final PsiMethod superMethod, final Project project) {
-    String implement = !method.hasModifierProperty(PsiModifier.ABSTRACT) && superMethod.hasModifierProperty(PsiModifier.ABSTRACT)
-                  ? InspectionsBundle.message("inspection.annotate.quickfix.implements")
-                  : InspectionsBundle.message("inspection.annotate.quickfix.overrides");
-    String message = InspectionsBundle.message("inspection.annotate.quickfix.overridden.method.messages",
-                                               UsageViewUtil.getDescriptiveName(method), implement,
-                                               UsageViewUtil.getDescriptiveName(superMethod));
-    String title = InspectionsBundle.message("inspection.annotate.quickfix.overridden.method.warning");
-    return Messages.showYesNoCancelDialog(project, message, title, Messages.getQuestionIcon());
-  }
-
-  protected boolean annotateOverriddenMethods() {
-    return false;
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return getName();
-  }
-
-  private void annotateMethod(@NotNull PsiMethod method) {
-    try {
-      new AddAnnotationFix(myAnnotation, method, myAnnotationsToRemove).invoke(method.getProject(), null, method.getContainingFile());
-    }
-    catch (IncorrectOperationException e) {
-      LOG.error(e);
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/DeleteThrowsFix.java b/java/java-impl/src/com/intellij/codeInspection/DeleteThrowsFix.java
deleted file mode 100644
index a8203d7..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/DeleteThrowsFix.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection;
-
-import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInsight.daemon.impl.quickfix.MethodThrowsFix;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiClassType;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiElement;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author cdr
- */
-public class DeleteThrowsFix implements LocalQuickFix {
-  private final MethodThrowsFix myQuickFix;
-
-  public DeleteThrowsFix(PsiMethod method, PsiClassType exceptionClass) {
-    myQuickFix = new MethodThrowsFix(method, exceptionClass, false, false);
-  }
-
-  @Override
-  @NotNull
-  public String getName() {
-    return myQuickFix.getText();
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return QuickFixBundle.message("fix.throws.list.family");
-  }
-
-  @Override
-  public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-    PsiElement element = descriptor.getPsiElement();
-    if (element == null) return;
-    final PsiFile psiFile = element.getContainingFile();
-    if (myQuickFix.isAvailable(project, null, psiFile)) {
-      myQuickFix.invoke(project, null, psiFile);
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java b/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java
deleted file mode 100644
index 5f5b0e2..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java
+++ /dev/null
@@ -1,95 +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.codeInspection;
-
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInsight.intention.HighPriorityAction;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.PsiDiamondTypeUtil;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * User: anna
- * Date: 1/28/11
- */
-public class ExplicitTypeCanBeDiamondInspection extends BaseJavaLocalInspectionTool {
-  public static final Logger LOG = Logger.getInstance("#" + ExplicitTypeCanBeDiamondInspection.class.getName());
-
-  @Nls
-  @NotNull
-  @Override
-  public String getGroupDisplayName() {
-    return GroupNames.LANGUAGE_LEVEL_SPECIFIC_GROUP_NAME;
-  }
-
-  @Nls
-  @NotNull
-  @Override
-  public String getDisplayName() {
-    return "Explicit type can be replaced with <>";
-  }
-
-  @Override
-  public boolean isEnabledByDefault() {
-    return true;
-  }
-
-  @NotNull
-  @Override
-  public String getShortName() {
-    return "Convert2Diamond";
-  }
-
-  @NotNull
-  @Override
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-      @Override
-      public void visitNewExpression(PsiNewExpression expression) {
-        if (PsiDiamondTypeUtil.canCollapseToDiamond(expression, expression, null)) {
-          final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference();
-          LOG.assertTrue(classReference != null);
-          final PsiReferenceParameterList parameterList = classReference.getParameterList();
-          LOG.assertTrue(parameterList != null);
-          holder.registerProblem(parameterList,  "Explicit type argument #ref #loc can be replaced with <>",
-                                 ProblemHighlightType.LIKE_UNUSED_SYMBOL, new ReplaceWithDiamondFix());
-        }
-      }
-    };
-  }
-
-  private static class ReplaceWithDiamondFix implements LocalQuickFix, HighPriorityAction {
-    @NotNull
-    @Override
-    public String getName() {
-      return "Replace with <>";
-    }
-
-    @NotNull
-    @Override
-    public String getFamilyName() {
-      return getName();
-    }
-
-    @Override
-    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-      PsiDiamondTypeUtil.replaceExplicitWithDiamond(descriptor.getPsiElement());
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/MoveToPackageFix.java b/java/java-impl/src/com/intellij/codeInspection/MoveToPackageFix.java
index 983c4fa..3fd32c3 100644
--- a/java/java-impl/src/com/intellij/codeInspection/MoveToPackageFix.java
+++ b/java/java-impl/src/com/intellij/codeInspection/MoveToPackageFix.java
@@ -99,10 +99,4 @@
       LOG.error(e);
     }
   }
-
-  public boolean startInWriteAction() {
-    return false;
-  }
-
-
 }
diff --git a/java/java-impl/src/com/intellij/codeInspection/PossibleHeapPollutionVarargsInspection.java b/java/java-impl/src/com/intellij/codeInspection/PossibleHeapPollutionVarargsInspection.java
deleted file mode 100644
index 565ebbd..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/PossibleHeapPollutionVarargsInspection.java
+++ /dev/null
@@ -1,174 +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.codeInspection;
-
-import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil;
-import com.intellij.codeInsight.intention.AddAnnotationFix;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.*;
-import com.intellij.psi.search.searches.OverridingMethodsSearch;
-import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.psi.util.PsiUtil;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * User: anna
- * Date: 1/28/11
- */
-public class PossibleHeapPollutionVarargsInspection extends BaseJavaLocalInspectionTool {
-  public static final Logger LOG = Logger.getInstance("#" + PossibleHeapPollutionVarargsInspection.class.getName());
-  @Nls
-  @NotNull
-  @Override
-  public String getGroupDisplayName() {
-    return GroupNames.LANGUAGE_LEVEL_SPECIFIC_GROUP_NAME;
-  }
-
-  @Nls
-  @NotNull
-  @Override
-  public String getDisplayName() {
-    return "Possible heap pollution from parameterized vararg type";
-  }
-
-  @Override
-  public boolean isEnabledByDefault() {
-    return true;
-  }
-
-  @NotNull
-  @Override
-  public String getShortName() {
-    return "SafeVarargsDetector";
-  }
-
-  @NotNull
-  @Override
-  public String getID() {
-    return "unchecked";
-  }
-
-  @NotNull
-  @Override
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-    return new HeapPollutionVisitor() {
-      @Override
-      protected void registerProblem(PsiMethod method, PsiIdentifier nameIdentifier) {
-        final LocalQuickFix quickFix;
-        if (method.hasModifierProperty(PsiModifier.FINAL) ||
-            method.hasModifierProperty(PsiModifier.STATIC) ||
-            method.isConstructor()) {
-          quickFix = new AnnotateAsSafeVarargsQuickFix();
-        }
-        else {
-          final PsiClass containingClass = method.getContainingClass();
-          LOG.assertTrue(containingClass != null);
-          boolean canBeFinal = !method.hasModifierProperty(PsiModifier.ABSTRACT) &&
-                               !containingClass.isInterface() &&
-                               OverridingMethodsSearch.search(method).findFirst() == null;
-          quickFix = canBeFinal ? new MakeFinalAndAnnotateQuickFix() : null;
-        }
-        holder.registerProblem(nameIdentifier, "Possible heap pollution from parameterized vararg type #loc", quickFix);
-      }
-    };
-  }
-
-  private static class AnnotateAsSafeVarargsQuickFix implements LocalQuickFix {
-    @NotNull
-    @Override
-    public String getName() {
-      return "Annotate as @SafeVarargs";
-    }
-
-    @NotNull
-    @Override
-    public String getFamilyName() {
-      return getName();
-    }
-
-    @Override
-    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-      final PsiElement psiElement = descriptor.getPsiElement();
-      if (psiElement instanceof PsiIdentifier) {
-        final PsiMethod psiMethod = (PsiMethod)psiElement.getParent();
-        if (psiMethod != null) {
-          new AddAnnotationFix("java.lang.SafeVarargs", psiMethod).applyFix(project, descriptor);
-        }
-      }
-    }
-  }
-
-  private static class MakeFinalAndAnnotateQuickFix implements LocalQuickFix {
-    @NotNull
-    @Override
-    public String getName() {
-      return "Make final and annotate as @SafeVarargs";
-    }
-
-    @NotNull
-    @Override
-    public String getFamilyName() {
-      return getName();
-    }
-
-    @Override
-    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-      final PsiElement psiElement = descriptor.getPsiElement();
-      if (psiElement instanceof PsiIdentifier) {
-        final PsiMethod psiMethod = (PsiMethod)psiElement.getParent();
-        psiMethod.getModifierList().setModifierProperty(PsiModifier.FINAL, true);
-        new AddAnnotationFix("java.lang.SafeVarargs", psiMethod).applyFix(project, descriptor);
-      }
-    }
-  }
-
-  public static abstract class HeapPollutionVisitor extends JavaElementVisitor {
-
-    @Override
-    public void visitMethod(PsiMethod method) {
-      super.visitMethod(method);
-      if (!PsiUtil.getLanguageLevel(method).isAtLeast(LanguageLevel.JDK_1_7)) return;
-      if (AnnotationUtil.isAnnotated(method, "java.lang.SafeVarargs", false)) return;
-      if (!method.isVarArgs()) return;
-
-      final PsiParameter psiParameter = method.getParameterList().getParameters()[method.getParameterList().getParametersCount() - 1];
-      final PsiType componentType = ((PsiEllipsisType)psiParameter.getType()).getComponentType();
-      if (GenericsHighlightUtil.isReifiableType(componentType)) {
-        return;
-      }
-      for (PsiReference reference : ReferencesSearch.search(psiParameter)) {
-        final PsiElement element = reference.getElement();
-        if (element instanceof PsiExpression && !PsiUtil.isAccessedForReading((PsiExpression)element)) {
-          return;
-        }
-      }
-      final PsiIdentifier nameIdentifier = method.getNameIdentifier();
-      if (nameIdentifier != null) {
-        //if (method.hasModifierProperty(PsiModifier.ABSTRACT)) return;
-        //final PsiClass containingClass = method.getContainingClass();
-        //if (containingClass == null || containingClass.isInterface()) return; do not add
-        registerProblem(method, nameIdentifier);
-      }
-    }
-
-    protected abstract void registerProblem(PsiMethod method, PsiIdentifier nameIdentifier);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/RedundantLambdaCodeBlockInspection.java b/java/java-impl/src/com/intellij/codeInspection/RedundantLambdaCodeBlockInspection.java
deleted file mode 100644
index 04d6533..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/RedundantLambdaCodeBlockInspection.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection;
-
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInsight.intention.HighPriorityAction;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.Function;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * User: anna
- */
-public class RedundantLambdaCodeBlockInspection extends BaseJavaLocalInspectionTool {
-  public static final Logger LOG = Logger.getInstance("#" + RedundantLambdaCodeBlockInspection.class.getName());
-
-  @Nls
-  @NotNull
-  @Override
-  public String getGroupDisplayName() {
-    return GroupNames.LANGUAGE_LEVEL_SPECIFIC_GROUP_NAME;
-  }
-
-  @Nls
-  @NotNull
-  @Override
-  public String getDisplayName() {
-    return "Lambda code block can be replaced with expression";
-  }
-
-  @Override
-  public boolean isEnabledByDefault() {
-    return true;
-  }
-
-  @NotNull
-  @Override
-  public String getShortName() {
-    return  "CodeBlock2Expr";
-  }
-
-  @NotNull
-  @Override
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-      @Override
-      public void visitLambdaExpression(PsiLambdaExpression expression) {
-        super.visitLambdaExpression(expression);
-        final PsiElement body = expression.getBody();
-        if (body instanceof PsiCodeBlock) {
-          PsiExpression psiExpression = getExpression((PsiCodeBlock)body);
-          if (psiExpression != null) {
-            final PsiElement errorElement;
-            final PsiElement parent = psiExpression.getParent();
-            if (parent instanceof PsiReturnStatement) {
-              errorElement = parent.getFirstChild();
-            } else {
-              errorElement = body.getFirstChild();
-            }
-            holder.registerProblem(errorElement, "Lambda code block can be replaced with one line expression",
-                                   ProblemHighlightType.LIKE_UNUSED_SYMBOL, new ReplaceWithExprFix());
-          }
-        }
-      }
-    };
-  }
-
-  @Nullable
-  private static PsiExpression getExpression(PsiCodeBlock body) {
-    final PsiStatement[] statements = body.getStatements();
-    if (statements.length == 1) {
-      if (statements[0] instanceof PsiBlockStatement) {
-        return getExpression(((PsiBlockStatement)statements[0]).getCodeBlock());
-      }
-      if (statements[0] instanceof PsiReturnStatement || statements[0] instanceof PsiExpressionStatement) {
-        if (statements[0] instanceof PsiReturnStatement) {
-          final PsiReturnStatement returnStatement = (PsiReturnStatement)statements[0];
-          return returnStatement.getReturnValue();
-        }
-        else {
-          final PsiExpression expression = ((PsiExpressionStatement)statements[0]).getExpression();
-          final PsiType psiType = expression.getType();
-          if (psiType != PsiType.VOID) {
-            return null;
-          }
-          return expression;
-        }
-      }
-    }
-    return null;
-  }
-
-  private static class ReplaceWithExprFix implements LocalQuickFix, HighPriorityAction {
-    @NotNull
-    @Override
-    public String getName() {
-      return "Replace with one line expression";
-    }
-
-    @NotNull
-    @Override
-    public String getFamilyName() {
-      return getName();
-    }
-
-    @Override
-    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-      final PsiElement element = descriptor.getPsiElement();
-      if (element != null) {
-        final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class);
-        if (lambdaExpression != null) {
-          final PsiElement body = lambdaExpression.getBody();
-          if (body != null) {
-            PsiExpression expression = getExpression((PsiCodeBlock)body);
-            if (expression != null) {
-              body.replace(expression);
-            }
-          }
-        }
-      }
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/RemoveAnnotationQuickFix.java b/java/java-impl/src/com/intellij/codeInspection/RemoveAnnotationQuickFix.java
deleted file mode 100644
index 2993b39..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/RemoveAnnotationQuickFix.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection;
-
-import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.ExternalAnnotationsManager;
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiAnnotation;
-import com.intellij.psi.PsiModifierListOwner;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author yole
- */
-public class RemoveAnnotationQuickFix implements LocalQuickFix {
-  private static final Logger LOG = Logger.getInstance("com.intellij.codeInsight.i18n.AnnotateNonNlsQuickfix");
-  private final PsiAnnotation myAnnotation;
-  private final PsiModifierListOwner myListOwner;
-
-  public RemoveAnnotationQuickFix(PsiAnnotation annotation, final PsiModifierListOwner listOwner) {
-    myAnnotation = annotation;
-    myListOwner = listOwner;
-  }
-
-  @Override
-  @NotNull
-  public String getName() {
-    return CodeInsightBundle.message("remove.annotation");
-  }
-
-  @Override
-  public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-    if (myAnnotation.isPhysical()) {
-      try {
-        if (!FileModificationService.getInstance().preparePsiElementForWrite(myAnnotation)) return;
-        myAnnotation.delete();
-      }
-      catch (IncorrectOperationException e) {
-        LOG.error(e);
-      }
-    } else {
-      ExternalAnnotationsManager.getInstance(project).deannotate(myListOwner, myAnnotation.getQualifiedName());
-    }
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return getName();
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInspection/ReplaceWithTernaryOperatorFix.java b/java/java-impl/src/com/intellij/codeInspection/ReplaceWithTernaryOperatorFix.java
deleted file mode 100644
index d492b7b..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/ReplaceWithTernaryOperatorFix.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection;
-
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.ScrollType;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.psi.util.PsiTypesUtil;
-import com.intellij.psi.util.PsiUtilBase;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author Danila Ponomarenko
- */
-public class ReplaceWithTernaryOperatorFix implements LocalQuickFix {
-  private final String myText;
-
-  @Override
-  @NotNull
-  public String getName() {
-    return InspectionsBundle.message("inspection.replace.ternary.quickfix", myText);
-  }
-
-  public ReplaceWithTernaryOperatorFix(@NotNull PsiExpression expressionToAssert) {
-    myText = expressionToAssert.getText();
-  }
-
-  @NotNull
-  @Override
-  public String getFamilyName() {
-    return InspectionsBundle.message("inspection.surround.if.family");
-  }
-
-  @Override
-  public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-    PsiElement element = descriptor.getPsiElement();
-    while (true) {
-      PsiElement parent = element.getParent();
-      if (parent instanceof PsiReferenceExpression || parent instanceof PsiMethodCallExpression) {
-        element = parent;
-      } else {
-        break;
-      }
-    }
-    if (!(element instanceof PsiExpression)) {
-      return;
-    }
-    final PsiExpression expression = (PsiExpression)element;
-
-    final PsiFile file = expression.getContainingFile();
-    if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
-    final PsiConditionalExpression conditionalExpression = replaceWthConditionalExpression(project, myText + "!=null", expression, suggestDefaultValue(expression));
-
-    final PsiExpression elseExpression = conditionalExpression.getElseExpression();
-    if (elseExpression != null) {
-      selectInEditor(elseExpression);
-    }
-  }
-
-  private static void selectInEditor(@NotNull PsiElement element) {
-    final Editor editor = PsiUtilBase.findEditor(element);
-    if (editor == null) return;
-
-    final TextRange expressionRange = element.getTextRange();
-    editor.getCaretModel().moveToOffset(expressionRange.getStartOffset());
-    editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
-    editor.getSelectionModel().setSelection(expressionRange.getStartOffset(), expressionRange.getEndOffset());
-  }
-
-  @NotNull
-  private static PsiConditionalExpression replaceWthConditionalExpression(@NotNull Project project,
-                                                                          @NotNull String condition,
-                                                                          @NotNull PsiExpression expression,
-                                                                          @NotNull String defaultValue) {
-    final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
-
-    final PsiElement parent = expression.getParent();
-    final PsiConditionalExpression conditionalExpression = (PsiConditionalExpression)factory.createExpressionFromText(
-      condition + " ? " + expression.getText() + " : " + defaultValue,
-      parent
-    );
-
-    final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
-    return (PsiConditionalExpression)expression.replace( codeStyleManager.reformat(conditionalExpression));
-  }
-
-  public static boolean isAvailable(@NotNull PsiExpression qualifier, @NotNull PsiExpression expression) {
-    if (!qualifier.isValid() || qualifier.getText() == null) {
-      return false;
-    }
-
-    return !(expression.getParent() instanceof PsiExpressionStatement);
-  }
-
-  private static String suggestDefaultValue(@NotNull PsiExpression expression) {
-    PsiType type = expression.getType();
-    return PsiTypesUtil.getDefaultValueOfType(type);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/SurroundWithIfFix.java b/java/java-impl/src/com/intellij/codeInspection/SurroundWithIfFix.java
index 72aaf61..3bdbc7c 100644
--- a/java/java-impl/src/com/intellij/codeInspection/SurroundWithIfFix.java
+++ b/java/java-impl/src/com/intellij/codeInspection/SurroundWithIfFix.java
@@ -60,7 +60,7 @@
     if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
     PsiElement[] elements = {anchorStatement};
     PsiElement prev = PsiTreeUtil.skipSiblingsBackward(anchorStatement, PsiWhiteSpace.class);
-    if (prev instanceof PsiComment && SuppressManager.getInstance().getSuppressedInspectionIdsIn(prev) != null) {
+    if (prev instanceof PsiComment && JavaSuppressionUtil.getSuppressedInspectionIdsIn(prev) != null) {
       elements = new PsiElement[]{prev, anchorStatement};
     }
     try {
diff --git a/java/java-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstance.java b/java/java-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstance.java
index 26afc96..46994c9 100644
--- a/java/java-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstance.java
+++ b/java/java-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstance.java
@@ -15,92 +15,19 @@
  */
 package com.intellij.codeInspection.accessStaticViaInstance;
 
-import com.intellij.codeInsight.daemon.JavaErrorMessages;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.codeInsight.daemon.impl.quickfix.AccessStaticViaInstanceFix;
-import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableFix;
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.psi.*;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.ArrayList;
+import com.intellij.psi.JavaResolveResult;
+import com.intellij.psi.PsiReferenceExpression;
 
 /**
  * User: anna
  * Date: 15-Nov-2005
  */
-public class AccessStaticViaInstance extends BaseJavaLocalInspectionTool {
-
-  public static final String ACCESS_STATIC_VIA_INSTANCE = "AccessStaticViaInstance";
-
+public class AccessStaticViaInstance extends AccessStaticViaInstanceBase {
   @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return "";
-  }
-
-  @Override
-  @NotNull
-  public String getDisplayName() {
-    return InspectionsBundle.message("access.static.via.instance");
-  }
-
-  @Override
-  @NotNull
-  @NonNls
-  public String getShortName() {
-    return ACCESS_STATIC_VIA_INSTANCE;
-  }
-
-  @Override
-  public String getAlternativeID() {
-    return "static-access";
-  }
-
-  @Override
-  public boolean isEnabledByDefault() {
-    return true;
-  }
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-      @Override public void visitReferenceExpression(PsiReferenceExpression expression) {
-        checkAccessStaticMemberViaInstanceReference(expression, holder, isOnTheFly);
-      }
-    };
-  }
-
-  private static void checkAccessStaticMemberViaInstanceReference(PsiReferenceExpression expr, ProblemsHolder holder, boolean onTheFly) {
-    JavaResolveResult result = expr.advancedResolve(false);
-    PsiElement resolved = result.getElement();
-
-    if (!(resolved instanceof PsiMember)) return;
-    PsiExpression qualifierExpression = expr.getQualifierExpression();
-    if (qualifierExpression == null) return;
-
-    if (qualifierExpression instanceof PsiReferenceExpression) {
-      final PsiElement qualifierResolved = ((PsiReferenceExpression)qualifierExpression).resolve();
-      if (qualifierResolved instanceof PsiClass || qualifierResolved instanceof PsiPackage) {
-        return;
-      }
-    }
-    if (!((PsiMember)resolved).hasModifierProperty(PsiModifier.STATIC)) return;
-
-    String description = JavaErrorMessages.message("static.member.accessed.via.instance.reference",
-                                                   HighlightUtil.formatType(qualifierExpression.getType()),
-                                                   HighlightMessageUtil.getSymbolName(resolved, result.getSubstitutor()));
-    if (!onTheFly) {
-      if (RemoveUnusedVariableFix.checkSideEffects(qualifierExpression, null, new ArrayList<PsiElement>())) {
-        holder.registerProblem(expr, description);
-        return;
-      }
-    }
-    holder.registerProblem(expr, description, new AccessStaticViaInstanceFix(expr, result, onTheFly));
+  protected AccessStaticViaInstanceFix createAccessStaticViaInstanceFix(PsiReferenceExpression expr,
+                                                                        boolean onTheFly,
+                                                                        JavaResolveResult result) {
+    return new AccessStaticViaInstanceFix(expr, result, onTheFly);
   }
 }
diff --git a/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalHandler.java b/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalHandler.java
deleted file mode 100644
index f6d5acf..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.canBeFinal;
-
-import com.intellij.openapi.extensions.ExtensionPointName;
-import com.intellij.openapi.extensions.Extensions;
-import com.intellij.psi.PsiMember;
-
-/**
- * User: anna
- * Date: 1/31/12
- */
-public abstract class CanBeFinalHandler {
-  public static final ExtensionPointName<CanBeFinalHandler> EP_NAME = ExtensionPointName.create("com.intellij.canBeFinal");
-
-  public abstract boolean canBeFinal(PsiMember member);
-
-  public static boolean allowToBeFinal(PsiMember member) {
-    for (CanBeFinalHandler handler : Extensions.getExtensions(EP_NAME)) {
-      if (!handler.canBeFinal(member)) return false;
-    }
-    return true;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/FieldAccessNotGuardedInspection.java b/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/FieldAccessNotGuardedInspection.java
deleted file mode 100644
index 458cc0f..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/FieldAccessNotGuardedInspection.java
+++ /dev/null
@@ -1,182 +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.concurrencyAnnotations;
-
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class FieldAccessNotGuardedInspection extends BaseJavaLocalInspectionTool {
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.CONCURRENCY_ANNOTATION_ISSUES;
-  }
-
-  @Override
-  @Nls
-  @NotNull
-  public String getDisplayName() {
-    return "Unguarded field access";
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return "FieldAccessNotGuarded";
-  }
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
-    return new Visitor(holder);
-  }
-
-
-  private static class Visitor extends JavaElementVisitor {
-    private final ProblemsHolder myHolder;
-
-    public Visitor(ProblemsHolder holder) {
-      myHolder = holder;
-    }
-
-    @Override
-    public void visitReferenceExpression(PsiReferenceExpression expression) {
-      final PsiElement referent = expression.resolve();
-      if (referent == null || !(referent instanceof PsiField)) {
-        return;
-      }
-      final PsiField field = (PsiField)referent;
-      final String guard = JCiPUtil.findGuardForMember(field);
-      if (guard == null) {
-        return;
-      }
-      final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expression, PsiMethod.class);
-      if (containingMethod != null && JCiPUtil.isGuardedBy(containingMethod, guard)) {
-        return;
-      }
-      if (containingMethod != null && containingMethod.isConstructor()) {
-        return;
-      }
-      if ("this".equals(guard)) {
-        if (containingMethod != null && containingMethod.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
-          return;
-        }
-      }
-
-      if (findLockTryStatement(expression, guard) != null) {
-        PsiElement lockExpr = expression;
-        while (lockExpr != null) {
-          PsiElement child = lockExpr;
-          while (child != null) {
-            if (isLockGuardStatement(guard, child, "lock")) return;
-            final PsiElement childParent = child.getParent();
-            if (child instanceof PsiMethodCallExpression &&
-                isCallOnGuard(guard, "tryLock", (PsiMethodCallExpression)child) &&
-                childParent instanceof PsiIfStatement &&
-                ((PsiIfStatement)childParent).getCondition() == child) {
-              return;
-            }
-            child = child.getPrevSibling();
-          }
-          lockExpr = lockExpr.getParent();
-        }
-      }
-
-      PsiElement check = expression;
-      while (true) {
-        final PsiSynchronizedStatement syncStatement = PsiTreeUtil.getParentOfType(check, PsiSynchronizedStatement.class);
-        if (syncStatement == null) {
-          break;
-        }
-        final PsiExpression lockExpression = syncStatement.getLockExpression();
-        if (lockExpression != null && lockExpression.getText().equals(guard))    //TODO: this isn't quite right,
-        {
-          return;
-        }
-        check = syncStatement;
-      }
-      myHolder.registerProblem(expression, "Access to field <code>#ref</code> outside of declared guards #loc");
-    }
-
-    @Nullable
-    private static PsiTryStatement findLockTryStatement(PsiReferenceExpression expression, String guard) {
-      PsiTryStatement tryStatement = PsiTreeUtil.getParentOfType(expression, PsiTryStatement.class);
-      while (tryStatement != null) {
-        PsiCodeBlock finallyBlock = tryStatement.getFinallyBlock();
-        if (finallyBlock != null) {
-          for (PsiStatement psiStatement : finallyBlock.getStatements()) {
-            if (isLockGuardStatement(guard, psiStatement, "unlock")) {
-              return tryStatement;
-            }
-          }
-        }
-        tryStatement = PsiTreeUtil.getParentOfType(tryStatement, PsiTryStatement.class);
-      }
-      return tryStatement;
-    }
-
-    private static boolean isLockGuardStatement(String guard, PsiElement element, final String lockMethodStart) {
-      if (element instanceof PsiExpressionStatement) {
-        final PsiExpression psiExpression = ((PsiExpressionStatement)element).getExpression();
-        if (psiExpression instanceof PsiMethodCallExpression) {
-          return isCallOnGuard(guard, lockMethodStart, (PsiMethodCallExpression)psiExpression);
-        }
-      }
-      return false;
-    }
-  }
-
-  private static boolean isCallOnGuard(String guard, String lockMethodStart, PsiMethodCallExpression psiExpression) {
-    final PsiReferenceExpression methodExpression = psiExpression.getMethodExpression();
-    final PsiExpression qualifierExpression = methodExpression.getQualifierExpression();
-    if (qualifierExpression != null) {
-      if (isCallOnGuard(guard, lockMethodStart, methodExpression, qualifierExpression)) {
-        return true;
-      } else if (qualifierExpression instanceof PsiReferenceExpression) {
-        final PsiElement resolve = ((PsiReferenceExpression)qualifierExpression).resolve();
-        if (resolve instanceof PsiField && ((PsiField)resolve).hasModifierProperty(PsiModifier.FINAL)) {
-          final PsiExpression initializer = ((PsiField)resolve).getInitializer();
-          return initializer != null && isCallOnGuard(guard, lockMethodStart, methodExpression, initializer);
-        }
-      }
-    }
-    return false;
-  }
-
-  private static boolean isCallOnGuard(String guard,
-                                       String lockMethodStart,
-                                       PsiReferenceExpression methodExpression,
-                                       PsiExpression qualifier) {
-    final String qualifierText = qualifier.getText();
-    if (qualifierText.startsWith(guard + ".") || qualifierText.equals(guard)) {
-      final PsiElement resolve = methodExpression.resolve();
-      if (resolve instanceof PsiMethod) {
-        final String methodName = ((PsiMethod)resolve).getName();
-        if (methodName.startsWith(lockMethodStart)) {
-          return true;
-        }
-      }
-    }
-    return false;
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/InstanceGuardedByStaticInspection.java b/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/InstanceGuardedByStaticInspection.java
deleted file mode 100644
index 9c66ee5..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/InstanceGuardedByStaticInspection.java
+++ /dev/null
@@ -1,127 +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.concurrencyAnnotations;
-
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.psi.*;
-import com.intellij.psi.javadoc.PsiDocTag;
-import com.intellij.psi.util.PsiTreeUtil;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-
-public class InstanceGuardedByStaticInspection extends BaseJavaLocalInspectionTool {
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.CONCURRENCY_ANNOTATION_ISSUES;
-  }
-
-  @Override
-  @Nls
-  @NotNull
-  public String getDisplayName() {
-    return "Instance member guarded by static field";
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return "InstanceGuardedByStatic";
-  }
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
-    return new Visitor(holder);
-  }
-
-  private static class Visitor extends JavaElementVisitor {
-    private final ProblemsHolder myHolder;
-
-    public Visitor(ProblemsHolder holder) {
-      myHolder = holder;
-    }
-
-
-    @Override
-    public void visitDocTag(PsiDocTag psiDocTag) {
-      super.visitDocTag(psiDocTag);
-      if (!JCiPUtil.isGuardedByTag(psiDocTag)) {
-        return;
-      }
-      final PsiMember member = PsiTreeUtil.getParentOfType(psiDocTag, PsiMember.class);
-      if (member == null) {
-        return;
-      }
-      if (member.hasModifierProperty(PsiModifier.STATIC)) {
-        return;
-      }
-      final String guardValue = JCiPUtil.getGuardValue(psiDocTag);
-
-      final PsiClass containingClass = PsiTreeUtil.getParentOfType(psiDocTag, PsiClass.class);
-      if (containingClass == null) {
-        return;
-      }
-      final PsiField guardField = containingClass.findFieldByName(guardValue, true);
-      if (guardField == null) {
-        return;
-      }
-      if (!guardField.hasModifierProperty(PsiModifier.STATIC)) {
-        return;
-      }
-      myHolder.registerProblem(psiDocTag, "Instance member guarded by static \"" + guardValue + "\" #loc");
-    }
-
-    @Override
-    public void visitAnnotation(PsiAnnotation annotation) {
-      super.visitAnnotation(annotation);
-      if (!JCiPUtil.isGuardedByAnnotation(annotation)) {
-        return;
-      }
-      final PsiMember member = PsiTreeUtil.getParentOfType(annotation, PsiMember.class);
-      if (member == null) {
-        return;
-      }
-      if (member.hasModifierProperty(PsiModifier.STATIC)) {
-        return;
-      }
-      final String guardValue = JCiPUtil.getGuardValue(annotation);
-      if (guardValue == null) {
-        return;
-      }
-
-      final PsiAnnotationMemberValue guardRef = annotation.findAttributeValue("value");
-      if (guardRef == null) {
-        return;
-      }
-      final PsiClass containingClass = PsiTreeUtil.getParentOfType(annotation, PsiClass.class);
-      if (containingClass == null) {
-        return;
-      }
-      final PsiField guardField = containingClass.findFieldByName(guardValue, true);
-      if (guardField == null) {
-        return;
-      }
-      if (!guardField.hasModifierProperty(PsiModifier.STATIC)) {
-        return;
-      }
-      myHolder.registerProblem(guardRef, "Instance member guarded by static #ref #loc");
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java b/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java
deleted file mode 100644
index daf675a..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java
+++ /dev/null
@@ -1,153 +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.concurrencyAnnotations;
-
-import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.psi.*;
-import com.intellij.psi.javadoc.PsiDocTag;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class JCiPUtil {
-  @NonNls
-  private static final String IMMUTABLE = "net.jcip.annotations.Immutable";
-  @NonNls
-  private static final String GUARDED_BY = "net.jcip.annotations.GuardedBy";
-  @NonNls
-  private static final String THREAD_SAFE = "net.jcip.annotations.ThreadSafe";
-
-  public static boolean isJCiPAnnotation(String ref) {
-    return "Immutable".equals(ref) || "GuardedBy".equals(ref) || "ThreadSafe".equals("ref");
-  }
-
-  private JCiPUtil() {
-  }
-
-  public static boolean isImmutable(PsiClass aClass) {
-    final PsiAnnotation annotation = AnnotationUtil.findAnnotation(aClass, IMMUTABLE);
-    if (annotation != null) {
-      return true;
-    }
-    final ImmutableTagVisitor visitor = new ImmutableTagVisitor();
-    aClass.accept(visitor);
-    return visitor.isFound();
-  }
-
-  @Nullable
-  public static String findGuardForMember(PsiMember member) {
-    final PsiAnnotation annotation = AnnotationUtil.findAnnotation(member, GUARDED_BY);
-    if (annotation != null) {
-      return getGuardValue(annotation);
-    }
-
-    final GuardedTagVisitor visitor = new GuardedTagVisitor();
-    member.accept(visitor);
-    return visitor.getGuardString();
-  }
-
-  public static boolean isGuardedBy(PsiMember member, String guard) {
-
-    final PsiAnnotation annotation = AnnotationUtil.findAnnotation(member, GUARDED_BY);
-    if (annotation != null) {
-      final PsiAnnotationParameterList parameters = annotation.getParameterList();
-      final PsiNameValuePair[] pairs = parameters.getAttributes();
-      final String fieldName = '"' + guard + '"';
-      for (PsiNameValuePair pair : pairs) {
-        final String name = pair.getName();
-        if (("value".equals(name) || name == null)) {
-          final PsiAnnotationMemberValue value = pair.getValue();
-          if (value != null && value.getText().equals(fieldName)) {
-            return true;
-          }
-        }
-      }
-    }
-    return false;
-  }
-
-  public static boolean isGuardedBy(PsiMember member, PsiField field) {
-    return isGuardedBy(member, field.getName());
-  }
-
-  public static boolean isGuardedByAnnotation(PsiAnnotation annotation) {
-    return GUARDED_BY.equals(annotation.getQualifiedName());
-  }
-
-  public static boolean isGuardedByTag(PsiDocTag tag) {
-    final String text = tag.getText();
-
-    return text.startsWith("@GuardedBy") && text.contains("(") && text.contains(")");
-  }
-
-  @Nullable
-  public static String getGuardValue(PsiAnnotation annotation) {
-    final PsiAnnotationParameterList parameters = annotation.getParameterList();
-    final PsiNameValuePair[] pairs = parameters.getAttributes();
-    for (PsiNameValuePair pair : pairs) {
-      final String name = pair.getName();
-      if ("value".equals(name) || name == null) {
-        final PsiAnnotationMemberValue psiAnnotationMemberValue = pair.getValue();
-        if (psiAnnotationMemberValue != null) {
-          final String value = psiAnnotationMemberValue.getText();
-          return value.substring(1, value.length() - 1).trim();
-        }
-      }
-    }
-    return null;
-  }
-
-  @NotNull
-  public static String getGuardValue(PsiDocTag tag) {
-    final String text = tag.getText();
-    return text.substring(text.indexOf((int)'(') + 1, text.indexOf((int)')')).trim();
-  }
-
-  private static class GuardedTagVisitor extends JavaRecursiveElementVisitor {
-    private String guardString = null;
-
-    @Override
-    public void visitDocTag(PsiDocTag tag) {
-      super.visitDocTag(tag);
-      final String text = tag.getText();
-      if (text.startsWith("@GuardedBy") && text.contains("(") && text.contains(")")) {
-        guardString = text.substring(text.indexOf((int)'(') + 1, text.indexOf((int)')'));
-      }
-    }
-
-    @Nullable
-    public String getGuardString() {
-      return guardString;
-    }
-  }
-
-  private static class ImmutableTagVisitor extends JavaRecursiveElementWalkingVisitor {
-    private boolean found = false;
-
-    @Override
-    public void visitDocTag(PsiDocTag tag) {
-      super.visitDocTag(tag);
-      final String text = tag.getText();
-      if (text.startsWith("@Immutable")) {
-        found = true;
-      }
-    }
-
-    public boolean isFound() {
-      return found;
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/NonFinalFieldInImmutableInspection.java b/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/NonFinalFieldInImmutableInspection.java
deleted file mode 100644
index 4f3bb97..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/NonFinalFieldInImmutableInspection.java
+++ /dev/null
@@ -1,67 +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.concurrencyAnnotations;
-
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.psi.*;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-
-public class NonFinalFieldInImmutableInspection extends BaseJavaLocalInspectionTool {
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.CONCURRENCY_ANNOTATION_ISSUES;
-  }
-
-  @Override
-  @Nls
-  @NotNull
-  public String getDisplayName() {
-    return "Non-final field in @Immutable class";
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return "NonFinalFieldInImmutable";
-  }
-
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-      @Override
-      public void visitField(PsiField field) {
-        super.visitField(field);
-        if (field.hasModifierProperty(PsiModifier.FINAL)) {
-          return;
-        }
-        final PsiClass containingClass = field.getContainingClass();
-        if (containingClass != null) {
-          if (!JCiPUtil.isImmutable(containingClass)) {
-            return;
-          }
-          holder.registerProblem(field, "Non-final field #ref in @Immutable class  #loc");
-        }
-      }
-    };
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/NonFinalGuardInspection.java b/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/NonFinalGuardInspection.java
deleted file mode 100644
index 33ac244..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/NonFinalGuardInspection.java
+++ /dev/null
@@ -1,115 +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.concurrencyAnnotations;
-
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.psi.*;
-import com.intellij.psi.javadoc.PsiDocTag;
-import com.intellij.psi.util.PsiTreeUtil;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-
-public class NonFinalGuardInspection extends BaseJavaLocalInspectionTool {
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.CONCURRENCY_ANNOTATION_ISSUES;
-  }
-
-  @Override
-  @Nls
-  @NotNull
-  public String getDisplayName() {
-    return "Non-final @GuardedBy field";
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return "NonFinalGuard";
-  }
-
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
-    return new Visitor(holder);
-  }
-
-  private static class Visitor extends JavaElementVisitor {
-    private final ProblemsHolder myHolder;
-
-    public Visitor(ProblemsHolder holder) {
-
-      myHolder = holder;
-    }
-
-    @Override
-    public void visitAnnotation(PsiAnnotation annotation) {
-      super.visitAnnotation(annotation);
-      if (!JCiPUtil.isGuardedByAnnotation(annotation)) {
-        return;
-      }
-      final String guardValue = JCiPUtil.getGuardValue(annotation);
-      if (guardValue == null || "this".equals(guardValue)) {
-        return;
-      }
-      final PsiClass containingClass = PsiTreeUtil.getParentOfType(annotation, PsiClass.class);
-      if (containingClass == null) {
-        return;
-      }
-      final PsiField guardField = containingClass.findFieldByName(guardValue, true);
-      if (guardField == null) {
-        return;
-      }
-      if (guardField.hasModifierProperty(PsiModifier.FINAL)) {
-        return;
-      }
-      final PsiAnnotationMemberValue member = annotation.findAttributeValue("value");
-      if (member == null) {
-        return;
-      }
-      myHolder.registerProblem(member, "Non-final @GuardedBy field #ref #loc");
-    }
-
-    @Override
-    public void visitDocTag(PsiDocTag psiDocTag) {
-      super.visitDocTag(psiDocTag);
-      if (!JCiPUtil.isGuardedByTag(psiDocTag)) {
-        return;
-      }
-      final String guardValue = JCiPUtil.getGuardValue(psiDocTag);
-      if ("this".equals(guardValue)) {
-        return;
-      }
-      final PsiClass containingClass = PsiTreeUtil.getParentOfType(psiDocTag, PsiClass.class);
-      if (containingClass == null) {
-        return;
-      }
-      final PsiField guardField = containingClass.findFieldByName(guardValue, true);
-      if (guardField == null) {
-        return;
-      }
-      if (guardField.hasModifierProperty(PsiModifier.FINAL)) {
-        return;
-      }
-      myHolder.registerProblem(psiDocTag, "Non-final @GuardedBy field \"" + guardValue + "\" #loc");
-    }
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/StaticGuardedByInstanceInspection.java b/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/StaticGuardedByInstanceInspection.java
deleted file mode 100644
index 9a8ed2b..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/StaticGuardedByInstanceInspection.java
+++ /dev/null
@@ -1,136 +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.concurrencyAnnotations;
-
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.psi.*;
-import com.intellij.psi.javadoc.PsiDocTag;
-import com.intellij.psi.util.PsiTreeUtil;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-
-public class StaticGuardedByInstanceInspection extends BaseJavaLocalInspectionTool {
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.CONCURRENCY_ANNOTATION_ISSUES;
-  }
-
-  @Override
-  @Nls
-  @NotNull
-  public String getDisplayName() {
-    return "Static member guarded by instance field or this";
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return "StaticGuardedByInstance";
-  }
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
-    return new Visitor(holder);
-  }
-
-  private static class Visitor extends JavaElementVisitor {
-    private final ProblemsHolder myHolder;
-
-    public Visitor(ProblemsHolder holder) {
-      myHolder = holder;
-    }
-
-    @Override
-    public void visitAnnotation(PsiAnnotation annotation) {
-      super.visitAnnotation(annotation);
-      if (!JCiPUtil.isGuardedByAnnotation(annotation)) {
-        return;
-      }
-      final PsiMember member = PsiTreeUtil.getParentOfType(annotation, PsiMember.class);
-      if (member == null) {
-        return;
-      }
-      if (!member.hasModifierProperty(PsiModifier.STATIC)) {
-        return;
-      }
-      final String guardValue = JCiPUtil.getGuardValue(annotation);
-      if (guardValue == null) {
-        return;
-      }
-
-      final PsiAnnotationMemberValue guardRef = annotation.findAttributeValue("value");
-      if (guardRef == null) {
-        return;
-      }
-      if ("this".equals(guardValue)) {
-        registerError(guardRef);
-      }
-      final PsiClass containingClass = PsiTreeUtil.getParentOfType(annotation, PsiClass.class);
-      if (containingClass == null) {
-        return;
-      }
-      final PsiField guardField = containingClass.findFieldByName(guardValue, true);
-      if (guardField == null) {
-        return;
-      }
-      if (guardField.hasModifierProperty(PsiModifier.STATIC)) {
-        return;
-      }
-      registerError(guardRef);
-    }
-
-    @Override
-    public void visitDocTag(PsiDocTag psiDocTag) {
-      super.visitDocTag(psiDocTag);
-      if (!JCiPUtil.isGuardedByTag(psiDocTag)) {
-        return;
-      }
-      final PsiMember member = PsiTreeUtil.getParentOfType(psiDocTag, PsiMember.class);
-      if (member == null) {
-        return;
-      }
-      if (!member.hasModifierProperty(PsiModifier.STATIC)) {
-        return;
-      }
-      final String guardValue = JCiPUtil.getGuardValue(psiDocTag);
-
-      if ("this".equals(guardValue)) {
-        registerError(psiDocTag);
-      }
-      final PsiClass containingClass = PsiTreeUtil.getParentOfType(psiDocTag, PsiClass.class);
-      if (containingClass == null) {
-        return;
-      }
-      final PsiField guardField = containingClass.findFieldByName(guardValue, true);
-      if (guardField == null) {
-        return;
-      }
-      if (guardField.hasModifierProperty(PsiModifier.STATIC)) {
-        return;
-      }
-      myHolder.registerProblem(psiDocTag, "Static member guarded by instance \"" + guardValue + "\" #loc");
-    }
-
-    private void registerError(PsiElement element) {
-      myHolder.registerProblem(element, "Static member guarded by instance #ref #loc");
-    }
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/UnknownGuardInspection.java b/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/UnknownGuardInspection.java
deleted file mode 100644
index b64bdb0..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/UnknownGuardInspection.java
+++ /dev/null
@@ -1,172 +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.concurrencyAnnotations;
-
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.*;
-import com.intellij.psi.javadoc.PsiDocTag;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.PsiTreeUtil;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * check locks according to http://www.javaconcurrencyinpractice.com/annotations/doc/net/jcip/annotations/GuardedBy.html
- */
-public class UnknownGuardInspection extends BaseJavaLocalInspectionTool {
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.CONCURRENCY_ANNOTATION_ISSUES;
-  }
-
-  @Override
-  @Nls
-  @NotNull
-  public String getDisplayName() {
-    return "Unknown @GuardedBy field";
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return "UnknownGuard";
-  }
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
-    return new Visitor(holder);
-  }
-
-  private static class Visitor extends JavaElementVisitor {
-    private final ProblemsHolder myHolder;
-
-    public Visitor(ProblemsHolder holder) {
-      myHolder = holder;
-    }
-
-    @Override
-    public void visitAnnotation(PsiAnnotation annotation) {
-      super.visitAnnotation(annotation);
-      if (!JCiPUtil.isGuardedByAnnotation(annotation)) {
-        return;
-      }
-      final String guardValue = JCiPUtil.getGuardValue(annotation);
-      if (guardValue == null || "this".equals(guardValue) || "itself".equals(guardValue)) {
-        return;
-      }
-      final PsiClass containingClass = PsiTreeUtil.getParentOfType(annotation, PsiClass.class);
-      if (containingClass == null) {
-        return;
-      }
-
-      if (containsFieldOrMethod(containingClass, guardValue)) return;
-
-      //class-name.class
-      final Project project = containingClass.getProject();
-      final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
-      if (guardValue.endsWith(".class") &&
-          facade.findClass(StringUtil.getPackageName(guardValue), GlobalSearchScope.allScope(project)) != null) {
-        return;
-      }
-
-      //class-name.field-name
-      final String classFQName = StringUtil.getPackageName(guardValue);
-      final PsiClass gClass = facade.findClass(classFQName, GlobalSearchScope.allScope(project));
-      if (gClass != null) {
-        final String fieldName = StringUtil.getShortName(guardValue);
-        if (gClass.findFieldByName(fieldName, true) != null) {
-          return;
-        }
-        //class-name.this
-        if (fieldName.equals("this")) {
-          return;
-        }
-      }
-
-      //class-name.this.field-name/method-name
-      final int thisIdx = guardValue.indexOf("this");
-      if (thisIdx > -1 && thisIdx + 1 < guardValue.length()) {
-        final PsiClass lockClass;
-        if (thisIdx == 0) {
-          lockClass = containingClass;
-        }
-        else {
-          final String fqn = guardValue.substring(0, thisIdx - 1);
-          lockClass = facade.findClass(fqn, GlobalSearchScope.allScope(project));
-        }
-
-        if (lockClass != null) {
-          final String fieldName = guardValue.substring(thisIdx + "this".length() + 1);
-          if (containsFieldOrMethod(lockClass, fieldName)) {
-            return;
-          }
-        }
-      }
-
-      final PsiAnnotationMemberValue member = annotation.findAttributeValue("value");
-      if (member == null) {
-        return;
-      }
-      myHolder.registerProblem(member, "Unknown @GuardedBy field #ref #loc");
-    }
-
-    private static boolean containsFieldOrMethod(PsiClass containingClass, String fieldOrMethod) {
-      //field-name
-      if (containingClass.findFieldByName(fieldOrMethod, true) != null) {
-        return true;
-      }
-
-      //method-name
-      if (fieldOrMethod.endsWith("()")) {
-        final PsiMethod[] methods = containingClass.findMethodsByName(StringUtil.trimEnd(fieldOrMethod, "()"), true);
-        for (PsiMethod method : methods) {
-          if (method.getParameterList().getParameters().length == 0) {
-            return true;
-          }
-        }
-      }
-      return false;
-    }
-
-    @Override
-    public void visitDocTag(PsiDocTag psiDocTag) {
-      super.visitDocTag(psiDocTag);
-      if (!JCiPUtil.isGuardedByTag(psiDocTag)) {
-        return;
-      }
-      final String guardValue = JCiPUtil.getGuardValue(psiDocTag);
-      if ("this".equals(guardValue)) {
-        return;
-      }
-      final PsiClass containingClass = PsiTreeUtil.getParentOfType(psiDocTag, PsiClass.class);
-      if (containingClass == null) {
-        return;
-      }
-      final PsiField guardField = containingClass.findFieldByName(guardValue, true);
-      if (guardField != null) {
-        return;
-      }
-      myHolder.registerProblem(psiDocTag, "Unknown @GuardedBy field \"" + guardValue + "\" #loc");
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/AnnotationsAwareDataFlowRunner.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/AnnotationsAwareDataFlowRunner.java
deleted file mode 100644
index 203ea42..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/AnnotationsAwareDataFlowRunner.java
+++ /dev/null
@@ -1,55 +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.dataFlow;
-
-import com.intellij.codeInsight.NullableNotNullManager;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiParameter;
-import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Collection;
-
-/**
- * @author peter
- */
-public class AnnotationsAwareDataFlowRunner extends DataFlowRunner {
-
-  @Override
-  protected Collection<DfaMemoryState> createInitialStates(@NotNull PsiElement psiBlock, InstructionVisitor visitor) {
-    final Collection<DfaMemoryState> initialStates = super.createInitialStates(psiBlock, visitor);
-    if (initialStates == null) {
-      return null;
-    }
-
-    final PsiElement parent = psiBlock.getParent();
-    if (parent instanceof PsiMethod) {
-      PsiMethod method = (PsiMethod)parent;
-
-      //todo move out from generic runner
-      for (PsiParameter parameter : method.getParameterList().getParameters()) {
-        if (NullableNotNullManager.isNotNull(parameter)) {
-          final DfaVariableValue value = getFactory().getVarFactory().createVariableValue(parameter, false);
-          for (final DfaMemoryState initialState : initialStates) {
-            initialState.applyNotNull(value);
-          }
-        }
-      }
-    }
-    return initialStates;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ConditionCheckDialog.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/ConditionCheckDialog.java
index 4e05e24..3363d94 100644
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ConditionCheckDialog.java
+++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/ConditionCheckDialog.java
@@ -46,13 +46,13 @@
  */
 public class ConditionCheckDialog extends DialogWrapper {
   private final Project myProject;
-  private final @NotNull Splitter mainSplitter;
-  private final @NotNull MethodsPanel myIsNullCheckMethodPanel;
-  private final @NotNull MethodsPanel myIsNotNullCheckMethodPanel;
-  private final @NotNull MethodsPanel myAssertIsNullMethodPanel;
-  private final @NotNull MethodsPanel myAssertIsNotNullMethodPanel;
-  private final @NotNull MethodsPanel myAssertTrueMethodPanel;
-  private final @NotNull MethodsPanel myAssertFalseMethodPanel;
+  @NotNull private final Splitter mainSplitter;
+  @NotNull private final MethodsPanel myIsNullCheckMethodPanel;
+  @NotNull private final MethodsPanel myIsNotNullCheckMethodPanel;
+  @NotNull private final MethodsPanel myAssertIsNullMethodPanel;
+  @NotNull private final MethodsPanel myAssertIsNotNullMethodPanel;
+  @NotNull private final MethodsPanel myAssertTrueMethodPanel;
+  @NotNull private final MethodsPanel myAssertFalseMethodPanel;
 
   public ConditionCheckDialog(Project project, String mainDialogTitle) {
     super(project, true);
@@ -140,12 +140,12 @@
    * Is Null, Is Not Null, Assert True and Assert False Method Panel at the top of the main Dialog.
    */
   class MethodsPanel {
-    private final @NotNull JBList myList;
-    private final @NotNull JPanel myPanel;
-    private final @NotNull Project myProject;
+    @NotNull private final JBList myList;
+    @NotNull private final JPanel myPanel;
+    @NotNull private final Project myProject;
     private Set<MethodsPanel> otherPanels;
 
-    public MethodsPanel(final List<ConditionChecker> checkers, final ConditionChecker.Type type, final @NotNull Project myProject) {
+    public MethodsPanel(final List<ConditionChecker> checkers, final ConditionChecker.Type type, @NotNull final Project myProject) {
       this.myProject = myProject;
       myList = new JBList(new CollectionListModel<ConditionChecker>(checkers));
       myPanel = new JPanel(new BorderLayout());
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlow.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlow.java
deleted file mode 100644
index 537d656..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlow.java
+++ /dev/null
@@ -1,104 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 11, 2002
- * Time: 3:05:34 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow;
-
-import com.intellij.codeInspection.dataFlow.instructions.FlushVariableInstruction;
-import com.intellij.codeInspection.dataFlow.instructions.Instruction;
-import com.intellij.codeInspection.dataFlow.value.DfaValueFactory;
-import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiVariable;
-import gnu.trove.TObjectIntHashMap;
-
-import java.util.ArrayList;
-
-public class ControlFlow {
-  private final ArrayList<Instruction> myInstructions = new ArrayList<Instruction>();
-  private final TObjectIntHashMap<PsiElement> myElementToStartOffsetMap = new TObjectIntHashMap<PsiElement>();
-  private final TObjectIntHashMap<PsiElement> myElementToEndOffsetMap = new TObjectIntHashMap<PsiElement>();
-  private DfaVariableValue[] myFields;
-  private final DfaValueFactory myFactory;
-
-  public ControlFlow(final DfaValueFactory factory) {
-    myFactory = factory;
-  }
-
-  public Instruction[] getInstructions(){
-    return myInstructions.toArray(new Instruction[myInstructions.size()]);
-  }
-
-  public int getInstructionCount() {
-    return myInstructions.size();
-  }
-
-  public void startElement(PsiElement psiElement) {
-    myElementToStartOffsetMap.put(psiElement, myInstructions.size());
-  }
-
-  public void finishElement(PsiElement psiElement) {
-    myElementToEndOffsetMap.put(psiElement, myInstructions.size());
-  }
-
-  public void addInstruction(Instruction instruction) {
-    instruction.setIndex(myInstructions.size());
-    myInstructions.add(instruction);
-  }
-
-  public void removeVariable(PsiVariable variable) {
-    DfaVariableValue var = myFactory.getVarFactory().createVariableValue(variable, false);
-    addInstruction(new FlushVariableInstruction(var));
-  }
-
-  public int getStartOffset(PsiElement element){
-    if (!myElementToStartOffsetMap.containsKey(element)) return -1;
-    return myElementToStartOffsetMap.get(element);
-  }
-
-  public int getEndOffset(PsiElement element){
-    if (!myElementToEndOffsetMap.containsKey(element)) return -1;
-    return myElementToEndOffsetMap.get(element);
-  }
-
-  public DfaVariableValue[] getFields() {
-    return myFields;
-  }
-
-  public void setFields(DfaVariableValue[] fields) {
-    myFields = fields;
-  }
-
-
-  public String toString() {
-    StringBuilder result = new StringBuilder();
-    final ArrayList<Instruction> instructions = myInstructions;
-
-    for (int i = 0; i < instructions.size(); i++) {
-      Instruction instruction = instructions.get(i);
-      result.append(Integer.toString(i)).append(": ").append(instruction.toString());
-      result.append("\n");
-    }
-    return result.toString();
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
deleted file mode 100644
index 664ffe4..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
+++ /dev/null
@@ -1,1683 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.dataFlow;
-
-import com.intellij.codeInsight.ConditionCheckManager;
-import com.intellij.codeInsight.ConditionChecker;
-import com.intellij.codeInsight.ExceptionUtil;
-import com.intellij.codeInspection.dataFlow.instructions.*;
-import com.intellij.codeInspection.dataFlow.value.*;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.tree.IElementType;
-import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.TypeConversionUtil;
-import com.intellij.refactoring.psi.PropertyUtils;
-import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.containers.Stack;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.*;
-
-import static com.intellij.psi.CommonClassNames.*;
-
-class ControlFlowAnalyzer extends JavaElementVisitor {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.ControlFlowAnalyzer");
-  private static final int NOT_FOUND = -10;
-
-  private static class CannotAnalyzeException extends RuntimeException { }
-
-  private final DfaValueFactory myFactory;
-  private ControlFlow myPass1Flow;
-  private ControlFlow myCurrentFlow;
-  private int myPassNumber;
-  private Set<DfaVariableValue> myFields;
-  private Stack<CatchDescriptor> myCatchStack;
-  private DfaValue myRuntimeException;
-  private DfaValue myError;
-
-  ControlFlowAnalyzer(final DfaValueFactory valueFactory) {
-    myFactory = valueFactory;
-  }
-
-  public ControlFlow buildControlFlow(PsiElement codeFragment) {
-    if (codeFragment == null) return null;
-
-    PsiManager manager = codeFragment.getManager();
-    GlobalSearchScope scope = codeFragment.getResolveScope();
-    myRuntimeException = myFactory.getNotNullFactory().create(PsiType.getJavaLangRuntimeException(manager, scope));
-    myError = myFactory.getNotNullFactory().create(PsiType.getJavaLangError(manager, scope));
-    myFields = new HashSet<DfaVariableValue>();
-    myCatchStack = new Stack<CatchDescriptor>();
-    myPassNumber = 1;
-    myPass1Flow = new ControlFlow(myFactory);
-    myCurrentFlow = myPass1Flow;
-
-    try {
-      codeFragment.accept(this);
-    }
-    catch (CannotAnalyzeException e) {
-      return null;
-    }
-
-    myPassNumber = 2;
-    final ControlFlow pass2Flow = new ControlFlow(myFactory);
-    myCurrentFlow = pass2Flow;
-
-    codeFragment.accept(this);
-
-    pass2Flow.setFields(myFields.toArray(new DfaVariableValue[myFields.size()]));
-
-    if (myPass1Flow.getInstructionCount() != pass2Flow.getInstructionCount()) {
-      LOG.error(Arrays.toString(myPass1Flow.getInstructions()) + "!=\n" + Arrays.toString(pass2Flow.getInstructions()));
-    }
-
-    addInstruction(new ReturnInstruction());
-
-    return pass2Flow;
-  }
-
-  private boolean myRecursionStopper = false;
-
-  private void addInstruction(Instruction i) {
-    ProgressManager.checkCanceled();
-
-    if (!myRecursionStopper) {
-      myRecursionStopper = true;
-      try {
-        // add extra conditional goto in order to handle possible runtime exceptions that could be caught by finally block
-        if (i instanceof BranchingInstruction || i instanceof AssignInstruction || i instanceof MethodCallInstruction) {
-          addConditionalRuntimeThrow();
-        }
-      }
-      finally {
-        myRecursionStopper = false;
-      }
-    }
-
-    myCurrentFlow.addInstruction(i);
-  }
-
-  private int getEndOffset(PsiElement element) {
-    return myPassNumber == 2 ? myPass1Flow.getEndOffset(element) : 0;
-  }
-
-  private int getStartOffset(PsiElement element) {
-    return myPassNumber == 2 ? myPass1Flow.getStartOffset(element) : 0;
-  }
-
-  private void startElement(PsiElement element) {
-    myCurrentFlow.startElement(element);
-  }
-
-  private void finishElement(PsiElement element) {
-    myCurrentFlow.finishElement(element);
-  }
-
-  @Override
-  public void visitErrorElement(PsiErrorElement element) {
-    throw new CannotAnalyzeException();
-  }
-
-  @Override public void visitAssignmentExpression(PsiAssignmentExpression expression) {
-    startElement(expression);
-
-    try {
-      PsiExpression lExpr = expression.getLExpression();
-      PsiExpression rExpr = expression.getRExpression();
-
-      if (rExpr == null) {
-        pushUnknown();
-        return;
-      }
-
-      lExpr.accept(this);
-
-      IElementType op = expression.getOperationTokenType();
-      PsiType type = expression.getType();
-      boolean isBoolean = PsiType.BOOLEAN.equals(type);
-      if (op == JavaTokenType.EQ) {
-        rExpr.accept(this);
-        generateBoxingUnboxingInstructionFor(rExpr, type);
-      }
-      else if (op == JavaTokenType.ANDEQ) {
-        if (isBoolean) {
-          generateNonLazyExpression(true, lExpr, rExpr, type);
-        }
-        else {
-          generateDefaultBinOp(lExpr, rExpr, type);
-        }
-      }
-      else if (op == JavaTokenType.OREQ) {
-        if (isBoolean) {
-          generateNonLazyExpression(false, lExpr, rExpr, type);
-        }
-        else {
-          generateDefaultBinOp(lExpr, rExpr, type);
-        }
-      }
-      else if (op == JavaTokenType.XOREQ) {
-        if (isBoolean) {
-          generateXorExpression(expression, new PsiExpression[]{lExpr, rExpr}, type);
-        }
-        else {
-          generateDefaultBinOp(lExpr, rExpr, type);
-        }
-      }
-      else {
-        generateDefaultBinOp(lExpr, rExpr, type);
-      }
-
-      addInstruction(new AssignInstruction(rExpr));
-    }
-    finally {
-      finishElement(expression);
-    }
-  }
-
-  private void generateDefaultBinOp(PsiExpression lExpr, PsiExpression rExpr, final PsiType exprType) {
-    lExpr.accept(this);
-    generateBoxingUnboxingInstructionFor(lExpr,exprType);
-    rExpr.accept(this);
-    generateBoxingUnboxingInstructionFor(rExpr,exprType);
-    addInstruction(new BinopInstruction(null, null, lExpr.getProject()));
-  }
-
-  @Override public void visitAssertStatement(PsiAssertStatement statement) {
-    startElement(statement);
-    final PsiExpression condition = statement.getAssertCondition();
-    final PsiExpression description = statement.getAssertDescription();
-    if (condition != null) {
-      condition.accept(this);
-      generateBoxingUnboxingInstructionFor(condition, PsiType.BOOLEAN);
-      addInstruction(new ConditionalGotoInstruction(getEndOffset(statement), false, condition));
-      if (description != null) {
-        description.accept(this);
-      }
-      addInstruction(new ReturnInstruction());
-    }
-    finishElement(statement);
-  }
-
-  @Override public void visitDeclarationStatement(PsiDeclarationStatement statement) {
-    startElement(statement);
-
-    PsiElement[] elements = statement.getDeclaredElements();
-    for (PsiElement element : elements) {
-      if (element instanceof PsiClass) {
-        addInstruction(new EmptyInstruction(element));
-      }
-      else if (element instanceof PsiVariable) {
-        PsiVariable variable = (PsiVariable)element;
-        PsiExpression initializer = variable.getInitializer();
-        if (initializer != null) {
-          initializeVariable(variable, initializer);
-        }
-      }
-    }
-
-    finishElement(statement);
-  }
-
-  @Override
-  public void visitField(PsiField field) {
-    PsiExpression initializer = field.getInitializer();
-    if (initializer != null) {
-      initializeVariable(field, initializer);
-    }
-  }
-
-  private void initializeVariable(PsiVariable variable, PsiExpression initializer) {
-    DfaVariableValue dfaVariable = myFactory.getVarFactory().createVariableValue(variable, false);
-    addInstruction(new PushInstruction(dfaVariable, initializer));
-    initializer.accept(this);
-    generateBoxingUnboxingInstructionFor(initializer, variable.getType());
-    addInstruction(new AssignInstruction(initializer));
-    addInstruction(new PopInstruction());
-  }
-
-  @Override
-  public void visitCodeFragment(JavaCodeFragment codeFragment) {
-    startElement(codeFragment);
-    if (codeFragment instanceof PsiExpressionCodeFragment) {
-      PsiExpression expression = ((PsiExpressionCodeFragment)codeFragment).getExpression();
-      if (expression != null) {
-        expression.accept(this);
-      }
-    }
-    finishElement(codeFragment);
-  }
-
-  @Override public void visitCodeBlock(PsiCodeBlock block) {
-    startElement(block);
-
-    for (PsiStatement statement : block.getStatements()) {
-      if (statement instanceof PsiDeclarationStatement) {
-        for (PsiElement declaration : ((PsiDeclarationStatement)statement).getDeclaredElements()) {
-          if (declaration instanceof PsiVariable) {
-            myCurrentFlow.removeVariable((PsiVariable)declaration);
-          }
-        }
-      }
-      statement.accept(this);
-    }
-
-    finishElement(block);
-  }
-
-  @Override public void visitBlockStatement(PsiBlockStatement statement) {
-    startElement(statement);
-    statement.getCodeBlock().accept(this);
-    finishElement(statement);
-  }
-
-  @Override public void visitBreakStatement(PsiBreakStatement statement) {
-    startElement(statement);
-
-    PsiStatement exitedStatement = statement.findExitedStatement();
-
-    if (exitedStatement != null) {
-      int offset = myPass1Flow.getEndOffset(exitedStatement);
-      if (offset == -1) offset = myPass1Flow.getInstructionCount();
-      addInstruction(new GotoInstruction(offset));
-    }
-
-    finishElement(statement);
-  }
-
-  @Override public void visitContinueStatement(PsiContinueStatement statement) {
-    startElement(statement);
-    PsiStatement continuedStatement = statement.findContinuedStatement();
-    if (continuedStatement != null) {
-      int offset = -1;
-      if (continuedStatement instanceof PsiForStatement) {
-        PsiStatement body = ((PsiForStatement)continuedStatement).getBody();
-        offset = myPass1Flow.getEndOffset(body);
-      }
-      else if (continuedStatement instanceof PsiWhileStatement) {
-        PsiStatement body = ((PsiWhileStatement)continuedStatement).getBody();
-        offset = myPass1Flow.getEndOffset(body);
-      }
-      else if (continuedStatement instanceof PsiDoWhileStatement) {
-        PsiStatement body = ((PsiDoWhileStatement)continuedStatement).getBody();
-        offset = myPass1Flow.getEndOffset(body);
-      }
-      else if (continuedStatement instanceof PsiForeachStatement) {
-        PsiStatement body = ((PsiForeachStatement)continuedStatement).getBody();
-        offset = myPass1Flow.getEndOffset(body);
-      }
-      Instruction instruction = offset == -1 ? new EmptyInstruction(null) : new GotoInstruction(offset);
-      addInstruction(instruction);
-    }
-    finishElement(statement);
-  }
-
-  @Override public void visitDoWhileStatement(PsiDoWhileStatement statement) {
-    startElement(statement);
-
-    PsiStatement body = statement.getBody();
-    if (body != null) {
-      body.accept(this);
-      PsiExpression condition = statement.getCondition();
-      if (condition != null) {
-        condition.accept(this);
-        generateBoxingUnboxingInstructionFor(condition, PsiType.BOOLEAN);
-        addInstruction(new ConditionalGotoInstruction(getStartOffset(statement), false, condition));
-      }
-    }
-
-    finishElement(statement);
-  }
-
-  @Override public void visitEmptyStatement(PsiEmptyStatement statement) {
-    startElement(statement);
-    finishElement(statement);
-  }
-
-  @Override public void visitExpressionStatement(PsiExpressionStatement statement) {
-    startElement(statement);
-    final PsiExpression expr = statement.getExpression();
-    expr.accept(this);
-    addInstruction(new PopInstruction());
-    finishElement(statement);
-  }
-
-  @Override public void visitExpressionListStatement(PsiExpressionListStatement statement) {
-    startElement(statement);
-    PsiExpression[] expressions = statement.getExpressionList().getExpressions();
-    for (PsiExpression expr : expressions) {
-      expr.accept(this);
-      addInstruction(new PopInstruction());
-    }
-    finishElement(statement);
-  }
-
-  @Override public void visitForeachStatement(PsiForeachStatement statement) {
-    startElement(statement);
-    final PsiParameter parameter = statement.getIterationParameter();
-    final PsiExpression iteratedValue = statement.getIteratedValue();
-
-    if (iteratedValue != null) {
-      iteratedValue.accept(this);
-      addInstruction(new FieldReferenceInstruction(iteratedValue, "Collection iterator or array.length"));
-    }
-
-    int offset = myCurrentFlow.getInstructionCount();
-    DfaVariableValue dfaVariable = myFactory.getVarFactory().createVariableValue(parameter, false);
-    addInstruction(new FlushVariableInstruction(dfaVariable));
-
-    pushUnknown();
-    addInstruction(new ConditionalGotoInstruction(getEndOffset(statement), true, null));
-
-    final PsiStatement body = statement.getBody();
-    if (body != null) {
-      body.accept(this);
-    }
-
-    addInstruction(new GotoInstruction(offset));
-
-    finishElement(statement);
-    myCurrentFlow.removeVariable(parameter);
-  }
-
-  @Override public void visitForStatement(PsiForStatement statement) {
-    startElement(statement);
-    final ArrayList<PsiElement> declaredVariables = new ArrayList<PsiElement>();
-
-    PsiStatement initialization = statement.getInitialization();
-    if (initialization != null) {
-      initialization.accept(this);
-      initialization.accept(new JavaRecursiveElementWalkingVisitor() {
-        @Override public void visitReferenceExpression(PsiReferenceExpression expression) {
-          visitElement(expression);
-        }
-
-        @Override public void visitDeclarationStatement(PsiDeclarationStatement statement) {
-          PsiElement[] declaredElements = statement.getDeclaredElements();
-          for (PsiElement element : declaredElements) {
-            if (element instanceof PsiVariable) {
-              declaredVariables.add(element);
-            }
-          }
-        }
-      });
-    }
-
-    PsiExpression condition = statement.getCondition();
-    if (condition != null) {
-      condition.accept(this);
-      generateBoxingUnboxingInstructionFor(condition, PsiType.BOOLEAN);
-    }
-    else {
-      addInstruction(new PushInstruction(null, null));
-    }
-    addInstruction(new ConditionalGotoInstruction(getEndOffset(statement), true, condition));
-
-    PsiStatement body = statement.getBody();
-    if (body != null) {
-      body.accept(this);
-    }
-
-    PsiStatement update = statement.getUpdate();
-    if (update != null) {
-      update.accept(this);
-    }
-
-    int offset = initialization != null
-                 ? getEndOffset(initialization)
-                 : getStartOffset(statement);
-
-    addInstruction(new GotoInstruction(offset));
-    finishElement(statement);
-
-    for (PsiElement declaredVariable : declaredVariables) {
-      PsiVariable psiVariable = (PsiVariable)declaredVariable;
-      myCurrentFlow.removeVariable(psiVariable);
-    }
-  }
-
-  @Override public void visitIfStatement(PsiIfStatement statement) {
-    startElement(statement);
-
-    PsiExpression condition = statement.getCondition();
-
-    PsiStatement thenStatement = statement.getThenBranch();
-    PsiStatement elseStatement = statement.getElseBranch();
-
-    int offset = elseStatement != null
-                 ? getStartOffset(elseStatement)
-                 : getEndOffset(statement);
-
-    if (condition != null) {
-      condition.accept(this);
-      generateBoxingUnboxingInstructionFor(condition, PsiType.BOOLEAN);
-      addInstruction(new ConditionalGotoInstruction(offset, true, condition));
-    }
-
-    if (thenStatement != null) {
-      thenStatement.accept(this);
-    }
-
-    if (elseStatement != null) {
-      offset = getEndOffset(statement);
-      Instruction instruction = new GotoInstruction(offset);
-      addInstruction(instruction);
-      elseStatement.accept(this);
-    }
-
-    finishElement(statement);
-  }
-
-  // in case of JspTemplateStatement
-  @Override public void visitStatement(PsiStatement statement) {
-    startElement(statement);
-    finishElement(statement);
-  }
-
-  @Override public void visitLabeledStatement(PsiLabeledStatement statement) {
-    startElement(statement);
-    PsiStatement childStatement = statement.getStatement();
-    if (childStatement != null) {
-      childStatement.accept(this);
-    }
-    finishElement(statement);
-  }
-
-  @Override public void visitReturnStatement(PsiReturnStatement statement) {
-    startElement(statement);
-
-    PsiExpression returnValue = statement.getReturnValue();
-    if (returnValue != null) {
-      returnValue.accept(this);
-      PsiMethod method = PsiTreeUtil.getParentOfType(statement, PsiMethod.class, true, PsiMember.class);
-      if (method != null) {
-        generateBoxingUnboxingInstructionFor(returnValue, method.getReturnType());
-      }
-      addInstruction(new CheckReturnValueInstruction(statement));
-    }
-
-    returnCheckingFinally();
-    finishElement(statement);
-  }
-
-  private void returnCheckingFinally() {
-    int finallyOffset = getFinallyOffset();
-    if (finallyOffset != NOT_FOUND) {
-      addInstruction(new GosubInstruction(finallyOffset));
-    }
-    addInstruction(new ReturnInstruction());
-  }
-
-  @Override public void visitSwitchLabelStatement(PsiSwitchLabelStatement statement) {
-    startElement(statement);
-    finishElement(statement);
-  }
-
-  @Override public void visitSwitchStatement(PsiSwitchStatement switchStmt) {
-    startElement(switchStmt);
-    PsiElementFactory psiFactory = JavaPsiFacade.getInstance(switchStmt.getProject()).getElementFactory();
-    PsiExpression caseExpression = switchStmt.getExpression();
-    Set<PsiEnumConstant> enumValues = null;
-    if (caseExpression != null /*&& !(caseExpression instanceof PsiReferenceExpression)*/) {
-      caseExpression.accept(this);
-
-      generateBoxingUnboxingInstructionFor(caseExpression, PsiType.INT);
-      final PsiClass psiClass = PsiUtil.resolveClassInType(caseExpression.getType());
-      if (psiClass != null && psiClass.isEnum()) {
-        addInstruction(new FieldReferenceInstruction(caseExpression, "switch statement expression"));
-        enumValues = new HashSet<PsiEnumConstant>();
-        for (PsiField f : psiClass.getFields()) {
-          if (f instanceof PsiEnumConstant) {
-            enumValues.add((PsiEnumConstant)f);
-          }
-        }
-      } else {
-        addInstruction(new PopInstruction());
-      }
-
-    }
-
-    PsiCodeBlock body = switchStmt.getBody();
-
-    if (body != null) {
-      PsiStatement[] statements = body.getStatements();
-      PsiSwitchLabelStatement defaultLabel = null;
-      for (PsiStatement statement : statements) {
-        if (statement instanceof PsiSwitchLabelStatement) {
-          PsiSwitchLabelStatement psiLabelStatement = (PsiSwitchLabelStatement)statement;
-          if (psiLabelStatement.isDefaultCase()) {
-            defaultLabel = psiLabelStatement;
-          }
-          else {
-            try {
-              int offset = getStartOffset(statement);
-              PsiExpression caseValue = psiLabelStatement.getCaseValue();
-
-              if (caseValue != null &&
-                  caseExpression instanceof PsiReferenceExpression &&
-                  ((PsiReferenceExpression)caseExpression).getQualifierExpression() == null &&
-                  JavaPsiFacade.getInstance(body.getProject()).getConstantEvaluationHelper().computeConstantExpression(caseValue) != null) {
-                PsiExpression psiComparison = psiFactory.createExpressionFromText(
-                  caseExpression.getText() + "==" + caseValue.getText(), switchStmt);
-                psiComparison.accept(this);
-              }
-              else {
-                pushUnknown();
-              }
-
-              addInstruction(new ConditionalGotoInstruction(offset, false, statement));
-
-              if (enumValues != null) {
-                if (caseValue instanceof PsiReferenceExpression) {
-                  //noinspection SuspiciousMethodCalls
-                  enumValues.remove(((PsiReferenceExpression)caseValue).resolve());
-                }
-              }
-            }
-            catch (IncorrectOperationException e) {
-              LOG.error(e);
-            }
-          }
-        }
-      }
-
-      if (enumValues == null || !enumValues.isEmpty()) {
-        int offset = defaultLabel != null ? getStartOffset(defaultLabel) : getEndOffset(body);
-        addInstruction(new GotoInstruction(offset));
-      }
-
-      body.accept(this);
-    }
-
-    finishElement(switchStmt);
-  }
-
-  @Override public void visitSynchronizedStatement(PsiSynchronizedStatement statement) {
-    startElement(statement);
-
-    PsiExpression lock = statement.getLockExpression();
-    if (lock != null) {
-      lock.accept(this);
-      addInstruction(new FieldReferenceInstruction(lock, "Synchronized value"));
-    }
-
-    addInstruction(new FlushVariableInstruction(null));
-
-    PsiCodeBlock body = statement.getBody();
-    if (body != null) {
-      body.accept(this);
-    }
-
-    finishElement(statement);
-  }
-
-  @Override public void visitThrowStatement(PsiThrowStatement statement) {
-    startElement(statement);
-
-    PsiExpression exception = statement.getException();
-
-    if (exception != null) {
-      exception.accept(this);
-      addThrowCode(exception.getType());
-    }
-
-    finishElement(statement);
-  }
-
-  private void addConditionalRuntimeThrow() {
-    for (int i = myCatchStack.size() - 1; i >= 0; i--) {
-      CatchDescriptor cd = myCatchStack.get(i);
-      if (cd.isFinally()) {
-        addConditionalRuntimeThrow(cd, false);
-        continue;
-      }
-
-      PsiType type = cd.getLubType();
-      if (type instanceof PsiClassType && ExceptionUtil.isUncheckedExceptionOrSuperclass((PsiClassType)type)) {
-        addConditionalRuntimeThrow(cd, true);
-        break;
-      }
-    }
-  }
-
-  private void addConditionalRuntimeThrow(CatchDescriptor cd, boolean forCatch) {
-    pushUnknown();
-    final ConditionalGotoInstruction branch = new ConditionalGotoInstruction(-1, false, null);
-    addInstruction(branch);
-    addInstruction(new EmptyStackInstruction());
-    if (forCatch) {
-      PsiType type = cd.getLubType();
-      boolean isRuntime = InheritanceUtil.isInheritor(type, JAVA_LANG_RUNTIME_EXCEPTION) || ExceptionUtil.isGeneralExceptionType(type);
-      boolean isError = InheritanceUtil.isInheritor(type, JAVA_LANG_ERROR) || type.equalsToText(JAVA_LANG_THROWABLE);
-      if (isRuntime != isError) {
-        addInstruction(new PushInstruction(isRuntime ? myRuntimeException : myError, null));
-        addGotoCatch(cd);
-      } else {
-        pushUnknown();
-        final ConditionalGotoInstruction branch2 = new ConditionalGotoInstruction(-1, false, null);
-        addInstruction(branch2);
-        addInstruction(new PushInstruction(myError, null));
-        addGotoCatch(cd);
-        branch2.setOffset(myCurrentFlow.getInstructionCount());
-        addInstruction(new PushInstruction(myRuntimeException, null));
-        addGotoCatch(cd);
-      }
-    }
-    else {
-      addInstruction(new GosubInstruction(cd.getJumpOffset(this)));
-      addInstruction(new ReturnInstruction());
-    }
-    branch.setOffset(myCurrentFlow.getInstructionCount());
-  }
-
-  private void addThrowCode(PsiType exceptionClass) {
-    if (exceptionClass == null) return;
-    for (int i = myCatchStack.size() - 1; i >= 0; i--) {
-      CatchDescriptor cd = myCatchStack.get(i);
-      if (cd.isFinally()) {
-        addInstruction(new GosubInstruction(cd.getJumpOffset(this)));
-      }
-      else if (cd.getType().isAssignableFrom(exceptionClass)) { // Definite catch.
-        addGotoCatch(cd);
-        return;
-      }
-      else if (cd.getType().isConvertibleFrom(exceptionClass)) { // Probable catch
-        addInstruction(new DupInstruction());
-        pushUnknown();
-        final ConditionalGotoInstruction branch = new ConditionalGotoInstruction(-1, false, null);
-        addInstruction(branch);
-        addGotoCatch(cd);
-        branch.setOffset(myCurrentFlow.getInstructionCount());
-      }
-    }
-
-    addInstruction(new ReturnInstruction());
-  }
-
-  /**
-   * Exception is expected on the stack.
-   */
-  private void addGotoCatch(CatchDescriptor cd) {
-    addInstruction(new PushInstruction(myFactory.getVarFactory().createVariableValue(cd.getParameter(), false), null));
-    addInstruction(new SwapInstruction());
-    myCurrentFlow.addInstruction(new AssignInstruction(null));
-    addInstruction(new PopInstruction());
-    addInstruction(new GotoInstruction(cd.getJumpOffset(this)));
-  }
-
-  private int getFinallyOffset() {
-    for (int i = myCatchStack.size() - 1; i >= 0; i--) {
-      CatchDescriptor cd = myCatchStack.get(i);
-      if (cd.isFinally()) return cd.getJumpOffset(this);
-    }
-
-    return NOT_FOUND;
-  }
-
-  private static class ApplyNotNullInstruction extends Instruction {
-    private PsiMethodCallExpression myCall;
-
-    private ApplyNotNullInstruction(PsiMethodCallExpression call) {
-      myCall = call;
-    }
-
-    @Override
-    public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState state, InstructionVisitor visitor) {
-      DfaValue value = state.pop();
-      DfaValueFactory factory = runner.getFactory();
-      if (state.applyCondition(
-        factory.getRelationFactory().createRelation(value, factory.getConstFactory().getNull(), JavaTokenType.EQEQ, true))) {
-        return nextInstruction(runner, state);
-      }
-      if (visitor instanceof StandardInstructionVisitor) {
-        ((StandardInstructionVisitor)visitor).skipConstantConditionReporting(myCall);
-      }
-      return DfaInstructionState.EMPTY_ARRAY;
-    }
-  }
-
-  private static class CatchDescriptor {
-    private final PsiType myType;
-    private final PsiParameter myParameter;
-    private final PsiCodeBlock myBlock;
-    private final boolean myIsFinally;
-
-    public CatchDescriptor(PsiCodeBlock finallyBlock) {
-      myType = null;
-      myParameter = null;
-      myBlock = finallyBlock;
-      myIsFinally = true;
-    }
-
-    public CatchDescriptor(PsiParameter parameter, PsiCodeBlock catchBlock) {
-      myType = parameter.getType();
-      myParameter = parameter;
-      myBlock = catchBlock;
-      myIsFinally = false;
-    }
-
-    public PsiType getType() {
-      return myType;
-    }
-
-    PsiType getLubType() {
-      PsiType type = myType;
-      if (type instanceof PsiDisjunctionType) {
-        return ((PsiDisjunctionType)type).getLeastUpperBound();
-      }
-      return type;
-    }
-
-    public boolean isFinally() {
-      return myIsFinally;
-    }
-
-    public int getJumpOffset(ControlFlowAnalyzer analyzer) {
-      return analyzer.getStartOffset(myBlock);
-    }
-
-    public PsiParameter getParameter() {
-      return myParameter;
-    }
-  }
-
-  @Override
-  public void visitTryStatement(PsiTryStatement statement) {
-    startElement(statement);
-
-    PsiResourceList resourceList = statement.getResourceList();
-    PsiCodeBlock tryBlock = statement.getTryBlock();
-    PsiCodeBlock finallyBlock = statement.getFinallyBlock();
-
-    if (finallyBlock != null) {
-      myCatchStack.push(new CatchDescriptor(finallyBlock));
-    }
-
-    int catchesPushCount = 0;
-    PsiCatchSection[] sections = statement.getCatchSections();
-    for (int i = sections.length - 1; i >= 0; i--) {
-      PsiCatchSection section = sections[i];
-      PsiCodeBlock catchBlock = section.getCatchBlock();
-      PsiParameter parameter = section.getParameter();
-      if (parameter != null && catchBlock != null) {
-        PsiType type = parameter.getType();
-        if (type instanceof PsiClassType || type instanceof PsiDisjunctionType) {
-          myCatchStack.push(new CatchDescriptor(parameter, catchBlock));
-          catchesPushCount++;
-          continue;
-        }
-      }
-      throw new CannotAnalyzeException();
-    }
-
-    int endOffset = finallyBlock == null ? getEndOffset(statement) : getStartOffset(finallyBlock) - 2;
-
-    if (resourceList != null) {
-      resourceList.accept(this);
-    }
-
-    if (tryBlock != null) {
-      tryBlock.accept(this);
-    }
-
-    for (int i = 0; i < catchesPushCount; i++) {
-      myCatchStack.pop();
-    }
-
-    addInstruction(new GotoInstruction(endOffset));
-
-    for (PsiCatchSection section : sections) {
-      section.accept(this);
-      addInstruction(new GotoInstruction(endOffset));
-    }
-
-    if (finallyBlock != null) {
-      myCatchStack.pop();
-      addInstruction(new GosubInstruction(getStartOffset(finallyBlock)));
-      addInstruction(new GotoInstruction(getEndOffset(statement)));
-      finallyBlock.accept(this);
-      addInstruction(new ReturnFromSubInstruction());
-    }
-
-    finishElement(statement);
-  }
-
-  @Override
-  public void visitCatchSection(PsiCatchSection section) {
-    PsiCodeBlock catchBlock = section.getCatchBlock();
-    if (catchBlock != null) {
-      catchBlock.accept(this);
-    }
-  }
-
-  @Override
-  public void visitResourceList(PsiResourceList resourceList) {
-    for (PsiResourceVariable variable : resourceList.getResourceVariables()) {
-      PsiExpression initializer = variable.getInitializer();
-      if (initializer != null) {
-        initializeVariable(variable, initializer);
-      }
-      PsiMethod closer = PsiUtil.getResourceCloserMethod(variable);
-      if (closer != null) {
-        addMethodThrows(closer);
-      }
-    }
-  }
-
-  @Override public void visitWhileStatement(PsiWhileStatement statement) {
-    startElement(statement);
-
-    PsiExpression condition = statement.getCondition();
-
-    if (condition != null) {
-      condition.accept(this);
-      generateBoxingUnboxingInstructionFor(condition, PsiType.BOOLEAN);
-      addInstruction(new ConditionalGotoInstruction(getEndOffset(statement), true, condition));
-    }
-
-    PsiStatement body = statement.getBody();
-    if (body != null) {
-      body.accept(this);
-    }
-
-    if (condition != null) {
-      addInstruction(new GotoInstruction(getStartOffset(statement)));
-    }
-
-    finishElement(statement);
-  }
-
-  @Override public void visitExpressionList(PsiExpressionList list) {
-    startElement(list);
-
-    PsiExpression[] expressions = list.getExpressions();
-    for (PsiExpression expression : expressions) {
-      expression.accept(this);
-    }
-
-    finishElement(list);
-  }
-
-  @Override public void visitExpression(PsiExpression expression) {
-    startElement(expression);
-    DfaValue dfaValue = myFactory.createValue(expression);
-    addInstruction(new PushInstruction(dfaValue, expression));
-    finishElement(expression);
-  }
-
-  @Override
-  public void visitArrayAccessExpression(PsiArrayAccessExpression expression) {
-    startElement(expression);
-    PsiExpression arrayExpression = expression.getArrayExpression();
-    arrayExpression.accept(this);
-    addInstruction(new FieldReferenceInstruction(expression, null));
-
-    PsiExpression indexExpression = expression.getIndexExpression();
-    if (indexExpression != null) {
-      indexExpression.accept(this);
-      generateBoxingUnboxingInstructionFor(indexExpression, PsiType.INT);
-      addInstruction(new PopInstruction());
-    }
-
-    pushTypeOrUnknown(arrayExpression);
-    finishElement(expression);
-  }
-
-  @Override
-  public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) {
-    startElement(expression);
-    PsiType type = expression.getType();
-    PsiExpression[] initializers = expression.getInitializers();
-    for (PsiExpression initializer : initializers) {
-      initializer.accept(this);
-      if (type instanceof PsiArrayType) {
-        generateBoxingUnboxingInstructionFor(initializer, ((PsiArrayType)type).getComponentType());
-      }
-      addInstruction(new PopInstruction());
-    }
-    pushUnknown();
-    finishElement(expression);
-  }
-
-  @Override
-  public void visitPolyadicExpression(PsiPolyadicExpression expression) {
-    startElement(expression);
-
-    try {
-      DfaValue dfaValue = myFactory.createValue(expression);
-      if (dfaValue != null) {
-        addInstruction(new PushInstruction(dfaValue, expression));
-        return;
-      }
-      IElementType op = expression.getOperationTokenType();
-
-      PsiExpression[] operands = expression.getOperands();
-      if (operands.length <= 1) {
-        pushUnknown();
-        return;
-      }
-      PsiType type = expression.getType();
-      if (op == JavaTokenType.ANDAND) {
-        generateAndExpression(operands, type);
-      }
-      else if (op == JavaTokenType.OROR) {
-        generateOrExpression(operands, type);
-      }
-      else if (op == JavaTokenType.XOR && PsiType.BOOLEAN.equals(type)) {
-        generateXorExpression(expression, operands, type);
-      }
-      else {
-        generateOther(expression, op, operands, type);
-      }
-    }
-    finally {
-      finishElement(expression);
-    }
-  }
-
-  private void generateOther(PsiPolyadicExpression expression, IElementType op, PsiExpression[] operands, PsiType type) {
-    op = substituteBinaryOperation(op, type);
-
-    PsiExpression lExpr = operands[0];
-    lExpr.accept(this);
-    PsiType lType = lExpr.getType();
-
-    for (int i = 1; i < operands.length; i++) {
-      PsiExpression rExpr = operands[i];
-      PsiType rType = rExpr.getType();
-
-      acceptBinaryRightOperand(op, type, lExpr, lType, rExpr, rType);
-      addInstruction(new BinopInstruction(op, expression.isPhysical() ? expression : null, expression.getProject()));
-
-      lExpr = rExpr;
-      lType = rType;
-    }
-  }
-
-  @Nullable
-  private static IElementType substituteBinaryOperation(IElementType op, PsiType type) {
-    if (JavaTokenType.PLUS == op && (type == null || !type.equalsToText(CommonClassNames.JAVA_LANG_STRING))) {
-      return null;
-    }
-    return op;
-  }
-
-  private void acceptBinaryRightOperand(@Nullable IElementType op, PsiType type,
-                                        PsiExpression lExpr, PsiType lType,
-                                        PsiExpression rExpr, PsiType rType) {
-    boolean comparing = op == JavaTokenType.EQEQ || op == JavaTokenType.NE;
-    boolean comparingRef = comparing
-                           && !TypeConversionUtil.isPrimitiveAndNotNull(lType)
-                           && !TypeConversionUtil.isPrimitiveAndNotNull(rType);
-
-    boolean comparingPrimitiveNumeric = comparing &&
-                                        TypeConversionUtil.isPrimitiveAndNotNull(lType) &&
-                                        TypeConversionUtil.isPrimitiveAndNotNull(rType) &&
-                                        TypeConversionUtil.isNumericType(lType) &&
-                                        TypeConversionUtil.isNumericType(rType);
-
-    PsiType castType = comparingPrimitiveNumeric ? TypeConversionUtil.isFloatOrDoubleType(lType) ? PsiType.DOUBLE : PsiType.LONG : type;
-
-    if (!comparingRef) {
-      generateBoxingUnboxingInstructionFor(lExpr,castType);
-    }
-
-    rExpr.accept(this);
-    if (!comparingRef) {
-      generateBoxingUnboxingInstructionFor(rExpr, castType);
-    }
-  }
-
-  private void generateBoxingUnboxingInstructionFor(PsiExpression expression, PsiType expectedType) {
-    PsiType exprType = expression.getType();
-
-    if (TypeConversionUtil.isPrimitiveAndNotNull(expectedType) && TypeConversionUtil.isPrimitiveWrapper(exprType)) {
-      addInstruction(new MethodCallInstruction(expression, MethodCallInstruction.MethodType.UNBOXING));
-    }
-    else if (TypeConversionUtil.isPrimitiveWrapper(expectedType) && TypeConversionUtil.isPrimitiveAndNotNull(exprType)) {
-      addInstruction(new MethodCallInstruction(expression, MethodCallInstruction.MethodType.BOXING));
-    }
-    else if (exprType != expectedType &&
-             TypeConversionUtil.isPrimitiveAndNotNull(exprType) &&
-             TypeConversionUtil.isPrimitiveAndNotNull(expectedType) &&
-             TypeConversionUtil.isNumericType(exprType) &&
-             TypeConversionUtil.isNumericType(expectedType)) {
-      addInstruction(new MethodCallInstruction(expression, MethodCallInstruction.MethodType.CAST, expectedType) {
-        @Override
-        public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-          return visitor.visitCast(this, runner, stateBefore);
-        }
-      });
-    }
-  }
-
-  private void generateXorExpression(PsiExpression expression, PsiExpression[] operands, final PsiType exprType) {
-    PsiExpression operand = operands[0];
-    operand.accept(this);
-    generateBoxingUnboxingInstructionFor(operand, exprType);
-    for (int i = 1; i < operands.length; i++) {
-      operand = operands[i];
-      operand.accept(this);
-      generateBoxingUnboxingInstructionFor(operand, exprType);
-      PsiElement psiAnchor = expression.isPhysical() ? expression : null;
-      addInstruction(new BinopInstruction(JavaTokenType.NE, psiAnchor, expression.getProject()));
-    }
-  }
-
-  private void generateOrExpression(PsiExpression[] operands, final PsiType exprType) {
-    for (int i = 0; i < operands.length; i++) {
-      PsiExpression operand = operands[i];
-      operand.accept(this);
-      generateBoxingUnboxingInstructionFor(operand, exprType);
-      PsiExpression nextOperand = i == operands.length - 1 ? null : operands[i + 1];
-      if (nextOperand != null) {
-        addInstruction(new ConditionalGotoInstruction(getStartOffset(nextOperand), true, operand));
-        addInstruction(new PushInstruction(myFactory.getConstFactory().getTrue(), null));
-        addInstruction(new GotoInstruction(getEndOffset(operands[operands.length - 1])));
-      }
-    }
-  }
-
-  private void generateNonLazyExpression(boolean and, PsiExpression lExpression, PsiExpression rExpression, PsiType exprType) {
-    rExpression.accept(this);
-    generateBoxingUnboxingInstructionFor(rExpression, exprType);
-
-    lExpression.accept(this);
-    generateBoxingUnboxingInstructionFor(lExpression, exprType);
-
-    ConditionalGotoInstruction toPopAndPushSuccess = new ConditionalGotoInstruction(-1, and, lExpression);
-    addInstruction(toPopAndPushSuccess);
-    GotoInstruction overPushSuccess = new GotoInstruction(-1);
-    addInstruction(overPushSuccess);
-
-    PopInstruction pop = new PopInstruction();
-    addInstruction(pop);
-    DfaConstValue constValue = and ? myFactory.getConstFactory().getFalse() : myFactory.getConstFactory().getTrue();
-    PushInstruction pushSuccess = new PushInstruction(constValue, null);
-    addInstruction(pushSuccess);
-
-    toPopAndPushSuccess.setOffset(pop.getIndex());
-    overPushSuccess.setOffset(pushSuccess.getIndex() + 1);
-  }
-
-  private void generateAndExpression(PsiExpression[] operands, final PsiType exprType) {
-    List<ConditionalGotoInstruction> branchToFail = new ArrayList<ConditionalGotoInstruction>();
-    for (PsiExpression operand : operands) {
-      operand.accept(this);
-      generateBoxingUnboxingInstructionFor(operand, exprType);
-
-      ConditionalGotoInstruction onFail = new ConditionalGotoInstruction(-1, true, operand);
-      branchToFail.add(onFail);
-      addInstruction(onFail);
-    }
-
-    addInstruction(new PushInstruction(myFactory.getConstFactory().getTrue(), null));
-    GotoInstruction toSuccess = new GotoInstruction(-1);
-    addInstruction(toSuccess);
-    PushInstruction pushFalse = new PushInstruction(myFactory.getConstFactory().getFalse(), null);
-    addInstruction(pushFalse);
-    for (ConditionalGotoInstruction toFail : branchToFail) {
-      toFail.setOffset(pushFalse.getIndex());
-    }
-    toSuccess.setOffset(pushFalse.getIndex()+1);
-
-  }
-
-  @Override public void visitClassObjectAccessExpression(PsiClassObjectAccessExpression expression) {
-    startElement(expression);
-    PsiElement[] children = expression.getChildren();
-    for (PsiElement child : children) {
-      child.accept(this);
-    }
-    pushUnknown();
-    finishElement(expression);
-  }
-
-  @Override public void visitConditionalExpression(PsiConditionalExpression expression) {
-    startElement(expression);
-
-    PsiExpression condition = expression.getCondition();
-
-    PsiExpression thenExpression = expression.getThenExpression();
-    PsiExpression elseExpression = expression.getElseExpression();
-
-    final int elseOffset = elseExpression == null ? getEndOffset(expression) - 1 : getStartOffset(elseExpression);
-    if (thenExpression != null) {
-      condition.accept(this);
-      generateBoxingUnboxingInstructionFor(condition, PsiType.BOOLEAN);
-      PsiType type = expression.getType();
-      addInstruction(new ConditionalGotoInstruction(elseOffset, true, condition));
-      thenExpression.accept(this);
-      generateBoxingUnboxingInstructionFor(thenExpression,type);
-
-      addInstruction(new GotoInstruction(getEndOffset(expression)));
-
-      if (elseExpression != null) {
-        elseExpression.accept(this);
-        generateBoxingUnboxingInstructionFor(elseExpression,type);
-      }
-      else {
-        pushUnknown();
-      }
-    }
-    else {
-      pushUnknown();
-    }
-
-    finishElement(expression);
-  }
-
-  private void pushUnknown() {
-    addInstruction(new PushInstruction(DfaUnknownValue.getInstance(), null));
-  }
-
-  @Override public void visitInstanceOfExpression(PsiInstanceOfExpression expression) {
-    startElement(expression);
-    PsiExpression operand = expression.getOperand();
-    PsiTypeElement checkType = expression.getCheckType();
-    if (checkType != null) {
-      operand.accept(this);
-      PsiType type = checkType.getType();
-      if (type instanceof PsiClassType) {
-        type = ((PsiClassType)type).rawType();
-      }
-      addInstruction(new PushInstruction(myFactory.getTypeFactory().create(type), null));
-      addInstruction(new InstanceofInstruction(expression, expression.getProject(), operand, type));
-    }
-    else {
-      pushUnknown();
-    }
-
-    finishElement(expression);
-  }
-
-  private void addMethodThrows(PsiMethod method) {
-    if (method != null) {
-      PsiClassType[] refs = method.getThrowsList().getReferencedTypes();
-      for (PsiClassType ref : refs) {
-        pushUnknown();
-        ConditionalGotoInstruction cond = new ConditionalGotoInstruction(NOT_FOUND, false, null);
-        addInstruction(cond);
-        addInstruction(new EmptyStackInstruction());
-        addInstruction(new PushInstruction(myFactory.getNotNullFactory().create(ref), null));
-        addThrowCode(ref);
-        cond.setOffset(myCurrentFlow.getInstructionCount());
-      }
-    }
-  }
-
-  @Override public void visitMethodCallExpression(PsiMethodCallExpression expression) {
-    try {
-      startElement(expression);
-
-      if (processSpecialMethods(expression)) {
-        return;
-      }
-
-      PsiReferenceExpression methodExpression = expression.getMethodExpression();
-      PsiExpression qualifierExpression = methodExpression.getQualifierExpression();
-
-      if (qualifierExpression != null) {
-        qualifierExpression.accept(this);
-      }
-      else {
-        pushUnknown();
-      }
-
-      PsiExpression[] expressions = expression.getArgumentList().getExpressions();
-      PsiElement method = methodExpression.resolve();
-      PsiParameter[] parameters = method instanceof PsiMethod ? ((PsiMethod)method).getParameterList().getParameters() : null;
-      for (int i = 0; i < expressions.length; i++) {
-        PsiExpression paramExpr = expressions[i];
-        paramExpr.accept(this);
-        if (parameters != null && i < parameters.length) {
-          generateBoxingUnboxingInstructionFor(paramExpr, parameters[i].getType());
-        }
-      }
-
-      MethodCallInstruction callInstruction = new MethodCallInstruction(expression, createChainedVariableValue(expression));
-      if (!DfaValueFactory.isEffectivelyUnqualified(methodExpression)) {
-        callInstruction.setShouldFlushFields(false);
-      }
-      addInstruction(callInstruction);
-
-      if (!myCatchStack.isEmpty()) {
-        addMethodThrows(expression.resolveMethod());
-      }
-
-      if (expressions.length == 1 && method instanceof PsiMethod &&
-          "equals".equals(((PsiMethod)method).getName()) && parameters.length == 1 &&
-          parameters[0].getType().equalsToText(CommonClassNames.JAVA_LANG_OBJECT) &&
-          PsiType.BOOLEAN.equals(((PsiMethod)method).getReturnType())) {
-        addInstruction(new PushInstruction(myFactory.getConstFactory().getFalse(), null));
-        addInstruction(new SwapInstruction());
-        addInstruction(new ConditionalGotoInstruction(getEndOffset(expression), true, null));
-
-        addInstruction(new PopInstruction());
-        addInstruction(new PushInstruction(myFactory.getConstFactory().getTrue(), null));
-
-        expressions[0].accept(this);
-        addInstruction(new ApplyNotNullInstruction(expression));
-      }
-    }
-    finally {
-      finishElement(expression);
-    }
-  }
-
-  private boolean processSpecialMethods(PsiMethodCallExpression expression) {
-    PsiReferenceExpression methodExpression = expression.getMethodExpression();
-    PsiExpression qualifierExpression = methodExpression.getQualifierExpression();
-
-    PsiMethod resolved = expression.resolveMethod();
-    if (resolved != null) {
-      @NonNls String methodName = resolved.getName();
-
-      PsiExpression[] params = expression.getArgumentList().getExpressions();
-      PsiClass owner = resolved.getContainingClass();
-      final int exitPoint = getEndOffset(expression) - 1;
-      if (owner != null) {
-        final String className = owner.getQualifiedName();
-        if ("java.lang.System".equals(className)) {
-          if ("exit".equals(methodName)) {
-            pushParameters(params, -1);
-            addInstruction(new ReturnInstruction());
-            return true;
-          }
-        }
-        else if ("junit.framework.Assert".equals(className) || "org.junit.Assert".equals(className) ||
-                 "junit.framework.TestCase".equals(className) || "org.testng.Assert".equals(className)) {
-          boolean testng = "org.testng.Assert".equals(className);
-          if ("fail".equals(methodName)) {
-            pushParameters(params, -1);
-            returnCheckingFinally();
-            return true;
-          }
-
-          int checkedParam = testng ? 0 : params.length - 1;
-          if ("assertTrue".equals(methodName)) {
-            pushParameters(params, checkedParam);
-            conditionalExit(exitPoint, false);
-            return true;
-          }
-          if ("assertFalse".equals(methodName)) {
-            pushParameters(params, checkedParam);
-            conditionalExit(exitPoint, true);
-            return true;
-          }
-          if ("assertNull".equals(methodName)) {
-            pushParameters(params, checkedParam);
-            handleAssertNullityMethod(expression, exitPoint, false);
-            return true;
-          }
-          if ("assertNotNull".equals(methodName)) {
-            pushParameters(params, checkedParam);
-            handleAssertNullityMethod(expression, exitPoint, true);
-            return true;
-          }
-          return false;
-        }
-      }
-
-      ConditionChecker checker = ConditionCheckManager.findConditionChecker(resolved);
-      if (checker != null) {
-        pushParameters(params, checker.getCheckedParameterIndex());
-
-        ConditionChecker.Type type = checker.getConditionCheckType();
-        if (type == ConditionChecker.Type.ASSERT_IS_NULL_METHOD || type == ConditionChecker.Type.ASSERT_IS_NOT_NULL_METHOD) {
-          handleAssertNullityMethod(expression, exitPoint, type == ConditionChecker.Type.ASSERT_IS_NOT_NULL_METHOD);
-        } else if (type == ConditionChecker.Type.IS_NULL_METHOD || type == ConditionChecker.Type.IS_NOT_NULL_METHOD) {
-          addInstruction(new PushInstruction(myFactory.getConstFactory().getNull(), null));
-          addInstruction(new BinopInstruction(type == ConditionChecker.Type.IS_NULL_METHOD ? JavaTokenType.EQEQ : JavaTokenType.NE, null, expression.getProject()));
-          
-          ConditionalGotoInstruction ifFails = new ConditionalGotoInstruction(-1, true, null);
-          GotoInstruction gotoEnd = new GotoInstruction(exitPoint);
-
-          addInstruction(ifFails);
-          pushUnknown();
-          addInstruction(gotoEnd);
-          ifFails.setOffset(myCurrentFlow.getInstructionCount());
-          addInstruction(new PushInstruction(myFactory.getConstFactory().getFalse(), null));
-          gotoEnd.setOffset(myCurrentFlow.getInstructionCount());
-
-        } else { //assertTrue or assertFalse
-          conditionalExit(exitPoint, type == ConditionChecker.Type.ASSERT_FALSE_METHOD);
-        }
-        return true;
-      }
-
-      // Idea project only.
-      if (qualifierExpression != null) {
-        if (qualifierExpression.textMatches("LOG")) {
-          final PsiType qualifierType = qualifierExpression.getType();
-          if (qualifierType != null && qualifierType.equalsToText("com.intellij.openapi.diagnostic.Logger")) {
-            if ("error".equals(methodName)) {
-              pushParameters(params, -1);
-              returnCheckingFinally();
-              return true;
-            }
-          }
-        }
-      }
-    }
-
-    return false;
-  }
-
-  private void handleAssertNullityMethod(PsiMethodCallExpression expression, int exitPoint, boolean assertNotNull) {
-    addInstruction(new PushInstruction(myFactory.getConstFactory().getNull(), null));
-    addInstruction(new BinopInstruction(JavaTokenType.EQEQ, null, expression.getProject()));
-    conditionalExit(exitPoint, assertNotNull);  // Exit if ==null for assertNull and != null for assertNotNull
-  }
-
-  private void conditionalExit(final int continuePoint, final boolean exitIfTrue) {
-    addInstruction(new ConditionalGotoInstruction(continuePoint, exitIfTrue, null));
-    addInstruction(new ReturnInstruction());
-    pushUnknown();
-  }
-
-  private void pushParameters(final PsiExpression[] params, final int leaveOnStack) {
-    for (int i = 0; i < params.length; i++) {
-      params[i].accept(this);
-      if (leaveOnStack != i) {
-        addInstruction(new PopInstruction());
-      }
-    }
-  }
-
-  private void pushTypeOrUnknown(PsiExpression expr) {
-    PsiType type = expr.getType();
-
-    final DfaValue dfaValue;
-    if (type instanceof PsiClassType) {
-      dfaValue = myFactory.getTypeFactory().create(type);
-    }
-    else {
-      dfaValue = null;
-    }
-
-    addInstruction(new PushInstruction(dfaValue, null));
-  }
-
-  @Override public void visitNewExpression(PsiNewExpression expression) {
-    startElement(expression);
-
-    pushUnknown();
-
-    if (expression.getType() instanceof PsiArrayType) {
-      final PsiExpression[] dimensions = expression.getArrayDimensions();
-      for (final PsiExpression dimension : dimensions) {
-        dimension.accept(this);
-      }
-      for (PsiExpression ignored : dimensions) {
-        addInstruction(new PopInstruction());
-      }
-      final PsiArrayInitializerExpression arrayInitializer = expression.getArrayInitializer();
-      if (arrayInitializer != null) {
-        for (final PsiExpression initializer : arrayInitializer.getInitializers()) {
-          initializer.accept(this);
-          addInstruction(new PopInstruction());
-        }
-      }
-      addInstruction(new MethodCallInstruction(expression, (DfaValue)null));
-    }
-    else {
-      final PsiExpressionList args = expression.getArgumentList();
-      PsiMethod ctr = expression.resolveConstructor();
-      if (args != null) {
-        PsiExpression[] params = args.getExpressions();
-        PsiParameter[] parameters = ctr == null ? null : ctr.getParameterList().getParameters();
-        for (int i = 0; i < params.length; i++) {
-          PsiExpression param = params[i];
-          param.accept(this);
-          if (parameters != null && i < parameters.length) {
-            generateBoxingUnboxingInstructionFor(param, parameters[i].getType());
-          }
-        }
-      }
-
-      addInstruction(new MethodCallInstruction(expression, (DfaValue)null));
-
-      if (!myCatchStack.isEmpty()) {
-        addMethodThrows(ctr);
-      }
-
-    }
-
-    finishElement(expression);
-  }
-
-  @Override public void visitParenthesizedExpression(PsiParenthesizedExpression expression) {
-    startElement(expression);
-    PsiExpression inner = expression.getExpression();
-    if (inner != null) {
-      inner.accept(this);
-    }
-    else {
-      pushUnknown();
-    }
-    finishElement(expression);
-  }
-
-  @Override public void visitPostfixExpression(PsiPostfixExpression expression) {
-    startElement(expression);
-
-    PsiExpression operand = expression.getOperand();
-    operand.accept(this);
-    generateBoxingUnboxingInstructionFor(operand, PsiType.INT);
-
-    addInstruction(new PopInstruction());
-    pushUnknown();
-
-    if (operand instanceof PsiReferenceExpression) {
-      PsiVariable psiVariable = DfaValueFactory.resolveUnqualifiedVariable((PsiReferenceExpression)expression.getOperand());
-      if (psiVariable != null) {
-        DfaVariableValue dfaVariable = myFactory.getVarFactory().createVariableValue(psiVariable, false);
-        addInstruction(new FlushVariableInstruction(dfaVariable));
-      }
-    }
-
-    finishElement(expression);
-  }
-
-  @Override public void visitPrefixExpression(PsiPrefixExpression expression) {
-    startElement(expression);
-
-    DfaValue dfaValue = myFactory.createValue(expression);
-    if (dfaValue == null) {
-      PsiExpression operand = expression.getOperand();
-
-      if (operand == null) {
-        pushUnknown();
-      }
-      else {
-        operand.accept(this);
-        PsiType type = expression.getType();
-        PsiPrimitiveType unboxed = PsiPrimitiveType.getUnboxedType(type);
-        generateBoxingUnboxingInstructionFor(operand, unboxed == null ? type : unboxed);
-        if (expression.getOperationTokenType() == JavaTokenType.EXCL) {
-          addInstruction(new NotInstruction());
-        }
-        else {
-          addInstruction(new PopInstruction());
-          pushUnknown();
-
-          if (operand instanceof PsiReferenceExpression) {
-            PsiVariable psiVariable = DfaValueFactory.resolveUnqualifiedVariable((PsiReferenceExpression)operand);
-            if (psiVariable != null) {
-              DfaVariableValue dfaVariable = myFactory.getVarFactory().createVariableValue(psiVariable, false);
-              addInstruction(new FlushVariableInstruction(dfaVariable));
-            }
-          }
-        }
-      }
-    }
-    else {
-      addInstruction(new PushInstruction(dfaValue, expression));
-    }
-
-    finishElement(expression);
-  }
-
-  @Override public void visitReferenceExpression(PsiReferenceExpression expression) {
-    startElement(expression);
-
-    final PsiExpression qualifierExpression = expression.getQualifierExpression();
-    if (qualifierExpression != null) {
-      qualifierExpression.accept(this);
-      addInstruction(expression.resolve() instanceof PsiField ? new FieldReferenceInstruction(expression, null) : new PopInstruction());
-    }
-
-    addInstruction(new PushInstruction(getExpressionDfaValue(expression), expression));
-
-    finishElement(expression);
-  }
-
-  @Nullable
-  private DfaValue getExpressionDfaValue(PsiReferenceExpression expression) {
-    DfaValue dfaValue = myFactory.createReferenceValue(expression);
-    if (dfaValue instanceof DfaVariableValue) {
-      DfaVariableValue dfaVariable = (DfaVariableValue)dfaValue;
-      if (dfaVariable.getPsiVariable() instanceof PsiField) {
-        myFields.add(dfaVariable);
-      }
-    }
-    if (dfaValue == null) {
-      PsiElement resolved = expression.resolve();
-      if (resolved instanceof PsiField) {
-        dfaValue = createDfaValueForAnotherInstanceMemberAccess(expression, (PsiField)resolved);
-      }
-    }
-    return dfaValue;
-  }
-
-  private DfaValue createDfaValueForAnotherInstanceMemberAccess(PsiReferenceExpression expression, PsiField field) {
-    DfaValue dfaValue = null;
-    if (expression.getQualifierExpression() != null) {
-      dfaValue = createChainedVariableValue(expression);
-    }
-    if (dfaValue == null) {
-      PsiType type = expression.getType();
-      return myFactory.createTypeValueWithNullability(type, DfaUtil.getElementNullability(type, field));
-    }
-    return dfaValue;
-  }
-
-  @Nullable
-  private DfaVariableValue createChainedVariableValue(@Nullable PsiExpression expression) {
-    if (expression instanceof PsiParenthesizedExpression) {
-      return createChainedVariableValue(((PsiParenthesizedExpression)expression).getExpression());
-    }
-
-    PsiReferenceExpression refExpr;
-    if (expression instanceof PsiMethodCallExpression) {
-      refExpr = ((PsiMethodCallExpression)expression).getMethodExpression();
-    }
-    else if (expression instanceof PsiReferenceExpression) {
-      refExpr = (PsiReferenceExpression)expression;
-    }
-    else {
-      return null;
-    }
-
-    PsiVariable var = resolveToVariable(refExpr);
-    if (var == null) {
-      return null;
-    }
-
-    boolean isCall = expression instanceof PsiMethodCallExpression;
-    PsiExpression qualifier = refExpr.getQualifierExpression();
-    if (qualifier == null) {
-      DfaVariableValue result = myFactory.getVarFactory().createVariableValue(var, refExpr.getType(), false, null, isCall);
-      if (var instanceof PsiField) {
-        myFields.add(result);
-      }
-      return result;
-    }
-
-    if (DfaUtil.isFinalField(var) || DfaUtil.isPlainMutableField(var)) {
-      DfaVariableValue qualifierValue = createChainedVariableValue(qualifier);
-      if (qualifierValue != null) {
-        return myFactory.getVarFactory().createVariableValue(var, refExpr.getType(), false, qualifierValue, isCall || qualifierValue.isViaMethods());
-      }
-    }
-    return null;
-  }
-
-  @Nullable
-  private static PsiVariable resolveToVariable(PsiReferenceExpression refExpr) {
-    PsiElement target = refExpr.resolve();
-    if (target instanceof PsiVariable) {
-      return (PsiVariable)target;
-    }
-    if (target instanceof PsiMethod) {
-      PsiMethod method = (PsiMethod)target;
-      if (PropertyUtils.isSimpleGetter(method)) {
-        return PropertyUtils.getSimplyReturnedField(method, PropertyUtils.getSingleReturnValue(method));
-      }
-    }
-    return null;
-  }
-
-  @Override public void visitSuperExpression(PsiSuperExpression expression) {
-    startElement(expression);
-    addInstruction(new PushInstruction(myFactory.getNotNullFactory().create(expression.getType()), null));
-    finishElement(expression);
-  }
-
-  @Override public void visitThisExpression(PsiThisExpression expression) {
-    startElement(expression);
-    addInstruction(new PushInstruction(myFactory.getNotNullFactory().create(expression.getType()), null));
-    finishElement(expression);
-  }
-
-  @Override public void visitLiteralExpression(PsiLiteralExpression expression) {
-    startElement(expression);
-
-    DfaValue dfaValue = myFactory.createLiteralValue(expression);
-    addInstruction(new PushInstruction(dfaValue, expression));
-
-    finishElement(expression);
-  }
-
-  @Override public void visitTypeCastExpression(PsiTypeCastExpression castExpression) {
-    startElement(castExpression);
-    PsiExpression operand = castExpression.getOperand();
-
-    if (operand != null) {
-      operand.accept(this);
-      generateBoxingUnboxingInstructionFor(operand, castExpression.getType());
-    }
-    else {
-      pushTypeOrUnknown(castExpression);
-    }
-
-    final PsiTypeElement typeElement = castExpression.getCastType();
-    if (typeElement != null && operand != null) {
-      addInstruction(new TypeCastInstruction(castExpression, operand, typeElement.getType()));
-    }
-    finishElement(castExpression);
-  }
-
-  @Override public void visitClass(PsiClass aClass) {
-  }
-
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java
index c4b90e7..348d3df 100644
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,43 +13,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Dec 24, 2001
- * Time: 2:46:32 PM
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
 package com.intellij.codeInspection.dataFlow;
 
-import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.NullableNotNullDialog;
-import com.intellij.codeInsight.NullableNotNullManager;
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInsight.daemon.impl.quickfix.SimplifyBooleanExpressionFix;
-import com.intellij.codeInsight.intention.impl.AddNullableAnnotationFix;
-import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.dataFlow.instructions.*;
-import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
+import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.codeInspection.LocalQuickFix;
+import com.intellij.codeInspection.SurroundWithIfFix;
 import com.intellij.ide.DataManager;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectManager;
-import com.intellij.openapi.util.Pair;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.SmartList;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import com.intellij.psi.PsiExpression;
 
 import javax.swing.*;
 import javax.swing.event.ChangeEvent;
@@ -57,497 +31,20 @@
 import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.util.*;
 import java.util.List;
 
-public class DataFlowInspection extends BaseLocalInspectionTool {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.DataFlowInspection");
-  @NonNls private static final String SHORT_NAME = "ConstantConditions";
-  public boolean SUGGEST_NULLABLE_ANNOTATIONS = false;
-  public boolean DONT_REPORT_TRUE_ASSERT_STATEMENTS = false;
-
+public class DataFlowInspection extends DataFlowInspectionBase {
+  @Override
+  protected void addSurroundWithIfFix(PsiExpression qualifier, List<LocalQuickFix> fixes) {
+    if (SurroundWithIfFix.isAvailable(qualifier)) {
+      fixes.add(new SurroundWithIfFix(qualifier));
+    }
+  }
   @Override
   public JComponent createOptionsPanel() {
     return new OptionsPanel();
   }
 
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-      @Override
-      public void visitField(PsiField field) {
-        analyzeCodeBlock(field, holder);
-      }
-
-      @Override
-      public void visitMethod(PsiMethod method) {
-        analyzeCodeBlock(method.getBody(), holder);
-      }
-
-      @Override
-      public void visitClassInitializer(PsiClassInitializer initializer) {
-        analyzeCodeBlock(initializer.getBody(), holder);
-      }
-    };
-  }
-
-  private void analyzeCodeBlock(@Nullable final PsiElement scope, ProblemsHolder holder) {
-    if (scope == null) return;
-    final StandardDataFlowRunner dfaRunner = new StandardDataFlowRunner(SUGGEST_NULLABLE_ANNOTATIONS);
-    final StandardInstructionVisitor visitor = new DataFlowInstructionVisitor(dfaRunner);
-    final RunnerResult rc = dfaRunner.analyzeMethod(scope, visitor);
-    if (rc == RunnerResult.OK) {
-      if (dfaRunner.problemsDetected(visitor)) {
-        createDescription(dfaRunner, holder, visitor);
-      }
-    }
-    else if (rc == RunnerResult.TOO_COMPLEX) {
-      if (scope.getParent() instanceof PsiMethod) {
-        PsiMethod method = (PsiMethod)scope.getParent();
-        final PsiIdentifier name = method.getNameIdentifier();
-        if (name != null) { // Might be null for synthetic methods like JSP page.
-          holder.registerProblem(name, InspectionsBundle.message("dataflow.too.complex"), ProblemHighlightType.WEAK_WARNING);
-        }
-      }
-    }
-  }
-
-  @Nullable
-  private static LocalQuickFix[] createNPEFixes(PsiExpression qualifier, PsiExpression expression) {
-    if (qualifier == null || expression == null) return null;
-    if (qualifier instanceof PsiMethodCallExpression) return null;
-    if (qualifier instanceof PsiLiteralExpression && ((PsiLiteralExpression)qualifier).getValue() == null) return null;
-
-    try {
-      final List<LocalQuickFix> fixes = new SmartList<LocalQuickFix>();
-
-      if (PsiUtil.getLanguageLevel(qualifier).isAtLeast(LanguageLevel.JDK_1_4)) {
-        final Project project = qualifier.getProject();
-        final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
-        final PsiBinaryExpression binary = (PsiBinaryExpression)elementFactory.createExpressionFromText("a != null", null);
-        binary.getLOperand().replace(qualifier);
-        fixes.add(new AddAssertStatementFix(binary));
-      }
-
-      if (SurroundWithIfFix.isAvailable(qualifier)) {
-        fixes.add(new SurroundWithIfFix(qualifier));
-      }
-      if (ReplaceWithTernaryOperatorFix.isAvailable(qualifier, expression)) {
-        fixes.add(new ReplaceWithTernaryOperatorFix(qualifier));
-      }
-      return fixes.toArray(new LocalQuickFix[fixes.size()]);
-    }
-    catch (IncorrectOperationException e) {
-      LOG.error(e);
-      return null;
-    }
-  }
-
-  private void createDescription(StandardDataFlowRunner runner, ProblemsHolder holder, StandardInstructionVisitor visitor) {
-    Pair<Set<Instruction>, Set<Instruction>> constConditions = runner.getConstConditionalExpressions();
-    Set<Instruction> trueSet = constConditions.getFirst();
-    Set<Instruction> falseSet = constConditions.getSecond();
-
-    ArrayList<Instruction> allProblems = new ArrayList<Instruction>();
-    allProblems.addAll(trueSet);
-    allProblems.addAll(falseSet);
-    allProblems.addAll(runner.getNPEInstructions());
-    allProblems.addAll(runner.getCCEInstructions());
-    allProblems.addAll(StandardDataFlowRunner.getRedundantInstanceofs(runner, visitor));
-
-    Collections.sort(allProblems, new Comparator<Instruction>() {
-      @Override
-      public int compare(Instruction i1, Instruction i2) {
-        return i1.getIndex() - i2.getIndex();
-      }
-    });
-
-    HashSet<PsiElement> reportedAnchors = new HashSet<PsiElement>();
-
-    for (Instruction instruction : allProblems) {
-      if (instruction instanceof MethodCallInstruction) {
-        reportCallMayProduceNpe(holder, (MethodCallInstruction)instruction);
-      }
-      else if (instruction instanceof FieldReferenceInstruction) {
-        reportFieldAccessMayProduceNpe(holder, (FieldReferenceInstruction)instruction);
-      }
-      else if (instruction instanceof TypeCastInstruction) {
-        reportCastMayFail(holder, (TypeCastInstruction)instruction);
-      }
-      else if (instruction instanceof BranchingInstruction) {
-        handleBranchingInstruction(holder, visitor, trueSet, falseSet, reportedAnchors, (BranchingInstruction)instruction);
-      }
-    }
-
-    reportNullableArguments(runner, holder);
-    reportNullableAssignments(runner, holder);
-    reportUnboxedNullables(runner, holder);
-    reportNullableReturns(runner, holder);
-    reportNullableArgumentsPassedToNonAnnotated(runner, holder);
-  }
-
-  private static void reportNullableArgumentsPassedToNonAnnotated(StandardDataFlowRunner runner, ProblemsHolder holder) {
-    Set<PsiExpression> exprs = runner.getNullableArgumentsPassedToNonAnnotatedParam();
-    for (PsiExpression expr : exprs) {
-      final String text = isNullLiteralExpression(expr)
-                          ? "Passing <code>null</code> argument to non annotated parameter"
-                          : "Argument <code>#ref</code> #loc might be null but passed to non annotated parameter";
-      LocalQuickFix[] fixes = createNPEFixes(expr, expr);
-      final PsiElement parent = expr.getParent();
-      if (parent instanceof PsiExpressionList) {
-        final int idx = ArrayUtil.find(((PsiExpressionList)parent).getExpressions(), expr);
-        if (idx > -1) {
-          final PsiElement gParent = parent.getParent();
-          if (gParent instanceof PsiCallExpression) {
-            final PsiMethod psiMethod = ((PsiCallExpression)gParent).resolveMethod();
-            if (psiMethod != null && psiMethod.getManager().isInProject(psiMethod) && AnnotationUtil.isAnnotatingApplicable(psiMethod)) {
-              final PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
-              if (idx < parameters.length) {
-                final AddNullableAnnotationFix addNullableAnnotationFix = new AddNullableAnnotationFix(parameters[idx]);
-                fixes = fixes == null ? new LocalQuickFix[]{addNullableAnnotationFix} : ArrayUtil.append(fixes, addNullableAnnotationFix);
-                holder.registerProblem(expr, text, fixes);
-              }
-            }
-          }
-        }
-      }
-
-    }
-  }
-
-  private static void reportCallMayProduceNpe(ProblemsHolder holder, MethodCallInstruction mcInstruction) {
-    if (mcInstruction.getCallExpression() instanceof PsiMethodCallExpression) {
-      PsiMethodCallExpression callExpression = (PsiMethodCallExpression)mcInstruction.getCallExpression();
-      LocalQuickFix[] fix = createNPEFixes(callExpression.getMethodExpression().getQualifierExpression(), callExpression);
-
-      holder.registerProblem(callExpression,
-                             InspectionsBundle.message("dataflow.message.npe.method.invocation"),
-                             fix);
-    }
-  }
-
-  private static void reportFieldAccessMayProduceNpe(ProblemsHolder holder, FieldReferenceInstruction frInstruction) {
-    PsiElement elementToAssert = frInstruction.getElementToAssert();
-    PsiExpression expression = frInstruction.getExpression();
-    if (expression instanceof PsiArrayAccessExpression) {
-      LocalQuickFix[] fix = createNPEFixes((PsiExpression)elementToAssert, expression);
-      holder.registerProblem(expression,
-                             InspectionsBundle.message("dataflow.message.npe.array.access"),
-                             fix);
-    }
-    else {
-      LocalQuickFix[] fix = createNPEFixes((PsiExpression)elementToAssert, expression);
-      holder.registerProblem(elementToAssert,
-                             InspectionsBundle.message("dataflow.message.npe.field.access"),
-                             fix);
-    }
-  }
-
-  private static void reportCastMayFail(ProblemsHolder holder, TypeCastInstruction instruction) {
-    PsiTypeCastExpression typeCast = instruction.getCastExpression();
-    holder.registerProblem(typeCast.getCastType(),
-                           InspectionsBundle.message("dataflow.message.cce", typeCast.getOperand().getText()));
-  }
-
-  private void handleBranchingInstruction(ProblemsHolder holder,
-                                          StandardInstructionVisitor visitor,
-                                          Set<Instruction> trueSet,
-                                          Set<Instruction> falseSet, HashSet<PsiElement> reportedAnchors, BranchingInstruction instruction) {
-    PsiElement psiAnchor = instruction.getPsiAnchor();
-    boolean underBinary = isAtRHSOfBooleanAnd(psiAnchor);
-    if (instruction instanceof InstanceofInstruction && visitor.isInstanceofRedundant((InstanceofInstruction)instruction)) {
-      if (visitor.canBeNull((BinopInstruction)instruction)) {
-        holder.registerProblem(psiAnchor,
-                               InspectionsBundle.message("dataflow.message.redundant.instanceof"),
-                               new RedundantInstanceofFix());
-      }
-      else {
-        final LocalQuickFix localQuickFix = createSimplifyBooleanExpressionFix(psiAnchor, true);
-        holder.registerProblem(psiAnchor,
-                               InspectionsBundle.message(underBinary ? "dataflow.message.constant.condition.when.reached" : "dataflow.message.constant.condition", Boolean.toString(true)),
-                               localQuickFix == null ? null : new LocalQuickFix[]{localQuickFix});
-      }
-    }
-    else if (psiAnchor instanceof PsiSwitchLabelStatement) {
-      if (falseSet.contains(instruction)) {
-        holder.registerProblem(psiAnchor,
-                               InspectionsBundle.message("dataflow.message.unreachable.switch.label"));
-      }
-    }
-    else if (psiAnchor != null && !reportedAnchors.contains(psiAnchor) && !isCompileConstantInIfCondition(psiAnchor)) {
-      boolean evaluatesToTrue = trueSet.contains(instruction);
-      if (onTheLeftSideOfConditionalAssignemnt(psiAnchor)) {
-        holder.registerProblem(
-          psiAnchor,
-          InspectionsBundle.message("dataflow.message.pointless.assignment.expression", Boolean.toString(evaluatesToTrue)),
-          createSimplifyToAssignmentFix()
-        );
-      }
-      else if (!skipReportingConstantCondition(visitor, psiAnchor, evaluatesToTrue)) {
-        final LocalQuickFix fix = createSimplifyBooleanExpressionFix(psiAnchor, evaluatesToTrue);
-        String message = InspectionsBundle.message(underBinary ?
-                                                   "dataflow.message.constant.condition.when.reached" :
-                                                   "dataflow.message.constant.condition", Boolean.toString(evaluatesToTrue));
-        holder.registerProblem(psiAnchor, message, fix == null ? null : new LocalQuickFix[]{fix});
-      }
-      reportedAnchors.add(psiAnchor);
-    }
-  }
-
-  private boolean skipReportingConstantCondition(StandardInstructionVisitor visitor, PsiElement psiAnchor, boolean evaluatesToTrue) {
-    return DONT_REPORT_TRUE_ASSERT_STATEMENTS && isAssertionEffectively(psiAnchor, evaluatesToTrue) ||
-           visitor.silenceConstantCondition(psiAnchor);
-  }
-
-  private static void reportNullableArguments(StandardDataFlowRunner runner, ProblemsHolder holder) {
-    Set<PsiExpression> exprs = runner.getNullableArguments();
-    for (PsiExpression expr : exprs) {
-      final String text = isNullLiteralExpression(expr)
-                          ? InspectionsBundle.message("dataflow.message.passing.null.argument")
-                          : InspectionsBundle.message("dataflow.message.passing.nullable.argument");
-      LocalQuickFix[] fixes = createNPEFixes(expr, expr);
-      holder.registerProblem(expr, text, fixes);
-    }
-  }
-
-  private static void reportNullableAssignments(StandardDataFlowRunner runner, ProblemsHolder holder) {
-    for (PsiExpression expr : runner.getNullableAssignments()) {
-      final String text = isNullLiteralExpression(expr)
-                          ? InspectionsBundle.message("dataflow.message.assigning.null")
-                          : InspectionsBundle.message("dataflow.message.assigning.nullable");
-      holder.registerProblem(expr, text);
-    }
-  }
-
-  private static void reportUnboxedNullables(StandardDataFlowRunner runner, ProblemsHolder holder) {
-    for (PsiExpression expr : runner.getUnboxedNullables()) {
-      holder.registerProblem(expr, InspectionsBundle.message("dataflow.message.unboxing"));
-    }
-  }
-
-  private static void reportNullableReturns(StandardDataFlowRunner runner, ProblemsHolder holder) {
-    for (PsiReturnStatement statement : runner.getNullableReturns()) {
-      final PsiExpression expr = statement.getReturnValue();
-      if (runner.isInNotNullMethod()) {
-        final String text = isNullLiteralExpression(expr)
-                            ? InspectionsBundle.message("dataflow.message.return.null.from.notnull")
-                            : InspectionsBundle.message("dataflow.message.return.nullable.from.notnull");
-        holder.registerProblem(expr, text);
-      }
-      else if (AnnotationUtil.isAnnotatingApplicable(statement)) {
-        final String text = isNullLiteralExpression(expr)
-                            ? InspectionsBundle.message("dataflow.message.return.null.from.notnullable")
-                            : InspectionsBundle.message("dataflow.message.return.nullable.from.notnullable");
-        final NullableNotNullManager manager = NullableNotNullManager.getInstance(expr.getProject());
-        holder.registerProblem(expr, text, new AnnotateMethodFix(manager.getDefaultNullable(), ArrayUtil.toStringArray(manager.getNotNulls())));
-      }
-    }
-  }
-
-  private static boolean isAssertionEffectively(PsiElement psiAnchor, boolean evaluatesToTrue) {
-    PsiElement parent = psiAnchor.getParent();
-    if (parent instanceof PsiAssertStatement) {
-      return evaluatesToTrue;
-    }
-    if (parent instanceof PsiIfStatement && psiAnchor == ((PsiIfStatement)parent).getCondition()) {
-      PsiStatement thenBranch = ((PsiIfStatement)parent).getThenBranch();
-      if (thenBranch instanceof PsiThrowStatement) {
-        return !evaluatesToTrue;
-      }
-      if (thenBranch instanceof PsiBlockStatement) {
-        PsiStatement[] statements = ((PsiBlockStatement)thenBranch).getCodeBlock().getStatements();
-        if (statements.length == 1 && statements[0] instanceof PsiThrowStatement) {
-          return !evaluatesToTrue;
-        }
-      }
-    }
-    return false;
-  }
-
-  private static boolean isAtRHSOfBooleanAnd(PsiElement expr) {
-    PsiElement cur = expr;
-
-    while (cur != null && !(cur instanceof PsiMember)) {
-      PsiElement parent = cur.getParent();
-
-      if (parent instanceof PsiBinaryExpression && cur == ((PsiBinaryExpression)parent).getROperand()) {
-        return true;
-      }
-
-      cur = parent;
-    }
-
-    return false;
-  }
-
-  private static boolean isCompileConstantInIfCondition(PsiElement element) {
-    if (!(element instanceof PsiReferenceExpression)) return false;
-    PsiElement resolved = ((PsiReferenceExpression)element).resolve();
-    if (!(resolved instanceof PsiField)) return false;
-    PsiField field = (PsiField)resolved;
-
-    if (!field.hasModifierProperty(PsiModifier.FINAL)) return false;
-    if (!field.hasModifierProperty(PsiModifier.STATIC)) return false;
-
-    PsiElement parent = element.getParent();
-    if (parent instanceof PsiPrefixExpression && ((PsiPrefixExpression)parent).getOperationTokenType() == JavaTokenType.EXCL) {
-      element = parent;
-      parent = parent.getParent();
-    }
-    return parent instanceof PsiIfStatement && ((PsiIfStatement)parent).getCondition() == element;
-  }
-
-  private static boolean isNullLiteralExpression(PsiExpression expr) {
-    if (expr instanceof PsiLiteralExpression) {
-      final PsiLiteralExpression literalExpression = (PsiLiteralExpression)expr;
-      return PsiType.NULL.equals(literalExpression.getType());
-    }
-    return false;
-  }
-
-  private static boolean onTheLeftSideOfConditionalAssignemnt(final PsiElement psiAnchor) {
-    final PsiElement parent = psiAnchor.getParent();
-    if (parent instanceof PsiAssignmentExpression) {
-      final PsiAssignmentExpression expression = (PsiAssignmentExpression)parent;
-      if (expression.getLExpression() == psiAnchor) return true;
-    }
-    return false;
-  }
-
-  @Nullable
-  private static LocalQuickFix createSimplifyBooleanExpressionFix(PsiElement element, final boolean value) {
-    SimplifyBooleanExpressionFix fix = createIntention(element, value);
-    if (fix == null) return null;
-    final String text = fix.getText();
-    return new LocalQuickFix() {
-      @Override
-      @NotNull
-      public String getName() {
-        return text;
-      }
-
-      @Override
-      public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-        final PsiElement psiElement = descriptor.getPsiElement();
-        if (psiElement == null) return;
-        final SimplifyBooleanExpressionFix fix = createIntention(psiElement, value);
-        if (fix == null) return;
-        try {
-          LOG.assertTrue(psiElement.isValid());
-          fix.invoke(project, null, psiElement.getContainingFile());
-        }
-        catch (IncorrectOperationException e) {
-          LOG.error(e);
-        }
-      }
-
-      @Override
-      @NotNull
-      public String getFamilyName() {
-        return InspectionsBundle.message("inspection.data.flow.simplify.boolean.expression.quickfix");
-      }
-    };
-  }
-
-  @NotNull
-  private static LocalQuickFix createSimplifyToAssignmentFix() {
-    return new LocalQuickFix() {
-      @NotNull
-      @Override
-      public String getName() {
-        return InspectionsBundle.message("inspection.data.flow.simplify.to.assignment.quickfix.name");
-      }
-
-      @NotNull
-      @Override
-      public String getFamilyName() {
-        return InspectionsBundle.message("inspection.data.flow.simplify.boolean.expression.quickfix");
-      }
-
-      @Override
-      public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-        final PsiElement psiElement = descriptor.getPsiElement();
-        if (psiElement == null) return;
-
-        final PsiAssignmentExpression assignmentExpression = PsiTreeUtil.getParentOfType(psiElement, PsiAssignmentExpression.class);
-        if (assignmentExpression == null) {
-          return;
-        }
-
-        final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
-        final String lExpressionText = assignmentExpression.getLExpression().getText();
-        final PsiExpression rExpression = assignmentExpression.getRExpression();
-        final String rExpressionText = rExpression != null ? rExpression.getText() : "";
-        assignmentExpression.replace(factory.createExpressionFromText(lExpressionText + " = " + rExpressionText, psiElement));
-      }
-    };
-  }
-
-  private static SimplifyBooleanExpressionFix createIntention(PsiElement element, boolean value) {
-    if (!(element instanceof PsiExpression)) return null;
-    final PsiExpression expression = (PsiExpression)element;
-    while (element.getParent() instanceof PsiExpression) {
-      element = element.getParent();
-    }
-    final SimplifyBooleanExpressionFix fix = new SimplifyBooleanExpressionFix(expression, value);
-    // simplify intention already active
-    if (!fix.isAvailable(element.getProject(), null, element.getContainingFile()) ||
-        SimplifyBooleanExpressionFix.canBeSimplified((PsiExpression)element)) {
-      return null;
-    }
-    return fix;
-  }
-
-  private static class RedundantInstanceofFix implements LocalQuickFix {
-    @Override
-    @NotNull
-    public String getName() {
-      return InspectionsBundle.message("inspection.data.flow.redundant.instanceof.quickfix");
-    }
-
-    @Override
-    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-      if (!FileModificationService.getInstance().preparePsiElementForWrite(descriptor.getPsiElement())) return;
-      final PsiElement psiElement = descriptor.getPsiElement();
-      if (psiElement instanceof PsiInstanceOfExpression) {
-        try {
-          final PsiExpression compareToNull = JavaPsiFacade.getInstance(psiElement.getProject()).getElementFactory().
-            createExpressionFromText(((PsiInstanceOfExpression)psiElement).getOperand().getText() + " != null", psiElement.getParent());
-          psiElement.replace(compareToNull);
-        }
-        catch (IncorrectOperationException e) {
-          LOG.error(e);
-        }
-      }
-    }
-
-    @Override
-    @NotNull
-    public String getFamilyName() {
-      return getName();
-    }
-  }
-
-
-  @Override
-  @NotNull
-  public String getDisplayName() {
-    return InspectionsBundle.message("inspection.data.flow.display.name");
-  }
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.BUGS_GROUP_NAME;
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return SHORT_NAME;
-  }
-
   private class OptionsPanel extends JPanel {
     private final JCheckBox mySuggestNullables;
     private final JCheckBox myDontReportTrueAsserts;
@@ -627,47 +124,4 @@
     }
   }
 
-  private static class DataFlowInstructionVisitor extends StandardInstructionVisitor {
-    private final StandardDataFlowRunner myRunner;
-
-    private DataFlowInstructionVisitor(StandardDataFlowRunner runner) {
-      myRunner = runner;
-    }
-
-    @Override
-    protected void onAssigningToNotNullableVariable(AssignInstruction instruction) {
-      myRunner.onAssigningToNotNullableVariable(instruction.getRExpression());
-    }
-
-    @Override
-    protected void onNullableReturn(CheckReturnValueInstruction instruction) {
-      myRunner.onNullableReturn(instruction.getReturn());
-    }
-
-    @Override
-    protected void onInstructionProducesCCE(TypeCastInstruction instruction) {
-      myRunner.onInstructionProducesCCE(instruction);
-    }
-
-    @Override
-    protected void onInstructionProducesNPE(Instruction instruction) {
-      if (instruction instanceof MethodCallInstruction &&
-          ((MethodCallInstruction)instruction).getMethodType() == MethodCallInstruction.MethodType.UNBOXING) {
-        myRunner.onUnboxingNullable(((MethodCallInstruction)instruction).getContext());
-      }
-      else {
-        myRunner.onInstructionProducesNPE(instruction);
-      }
-    }
-
-    @Override
-    protected void onPassingNullParameter(PsiExpression arg) {
-      myRunner.onPassingNullParameter(arg);
-    }
-
-    @Override
-    protected void onPassingNullParameterToNonAnnotated(DataFlowRunner runner, PsiExpression arg) {
-      myRunner.onPassingNullParameterToNonAnnotated(arg);
-    }
-  }
 }
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java
deleted file mode 100644
index 0340029..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java
+++ /dev/null
@@ -1,274 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 28, 2002
- * Time: 10:16:39 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow;
-
-import com.intellij.codeInspection.dataFlow.instructions.BranchingInstruction;
-import com.intellij.codeInspection.dataFlow.instructions.EmptyInstruction;
-import com.intellij.codeInspection.dataFlow.instructions.Instruction;
-import com.intellij.codeInspection.dataFlow.instructions.MethodCallInstruction;
-import com.intellij.codeInspection.dataFlow.value.DfaValueFactory;
-import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.Pair;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import gnu.trove.THashSet;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.*;
-
-public class DataFlowRunner {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.DataFlowRunner");
-  private static final Key<Integer> TOO_EXPENSIVE_HASH = Key.create("TOO_EXPENSIVE_HASH");
-  public static final long ourTimeLimit = 1000 * 1000 * 1000; //1 sec in nanoseconds
-
-  private Instruction[] myInstructions;
-  private DfaVariableValue[] myFields;
-  private final DfaValueFactory myValueFactory = new DfaValueFactory();
-
-  // Maximum allowed attempts to process instruction. Fail as too complex to process if certain instruction
-  // is executed more than this limit times.
-  public static final int MAX_STATES_PER_BRANCH = 300;
-
-  public Instruction getInstruction(int index) {
-    return myInstructions[index];
-  }
-
-  protected DataFlowRunner() {
-  }
-
-  public DfaValueFactory getFactory() {
-    return myValueFactory;
-  }
-
-  @Nullable
-  protected Collection<DfaMemoryState> createInitialStates(@NotNull PsiElement psiBlock, InstructionVisitor visitor) {
-    PsiClass containingClass = PsiTreeUtil.getParentOfType(psiBlock, PsiClass.class);
-    if (containingClass != null && PsiUtil.isLocalOrAnonymousClass(containingClass)) {
-      final PsiElement parent = containingClass.getParent();
-      final PsiCodeBlock block = DfaUtil.getTopmostBlockInSameClass(parent);
-      if ((parent instanceof PsiNewExpression || parent instanceof PsiDeclarationStatement) && block != null) {
-        final EnvironmentalInstructionVisitor envVisitor = new EnvironmentalInstructionVisitor(visitor, parent);
-        final RunnerResult result = analyzeMethod(block, envVisitor);
-        if (result == RunnerResult.OK) {
-          final Collection<DfaMemoryState> closureStates = envVisitor.getClosureStates();
-          if (!closureStates.isEmpty()) {
-            return closureStates;
-          }
-        }
-        return null;
-      }
-    }
-
-    return Arrays.asList(createMemoryState());
-  }
-
-  public final RunnerResult analyzeMethod(@NotNull PsiElement psiBlock, InstructionVisitor visitor) {
-    try {
-      final Collection<DfaMemoryState> initialStates = createInitialStates(psiBlock, visitor);
-      if (initialStates == null) return RunnerResult.NOT_APPLICABLE;
-
-      final ControlFlow flow = createControlFlowAnalyzer().buildControlFlow(psiBlock);
-      if (flow == null) return RunnerResult.NOT_APPLICABLE;
-
-      int endOffset = flow.getInstructionCount();
-      myInstructions = flow.getInstructions();
-      myFields = flow.getFields();
-
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Analyzing code block: " + psiBlock.getText());
-        for (int i = 0; i < myInstructions.length; i++) {
-          Instruction instruction = myInstructions[i];
-          LOG.debug(i + ": " + instruction.toString());
-        }
-      }
-
-      Integer tooExpensiveHash = psiBlock.getUserData(TOO_EXPENSIVE_HASH);
-      if (tooExpensiveHash != null && tooExpensiveHash == psiBlock.getText().hashCode()) {
-        LOG.debug("Too complex because hasn't changed since being too complex already");
-        return RunnerResult.TOO_COMPLEX;
-      }
-
-      final ArrayList<DfaInstructionState> queue = new ArrayList<DfaInstructionState>();
-      for (final DfaMemoryState initialState : initialStates) {
-        queue.add(new DfaInstructionState(myInstructions[0], initialState));
-      }
-
-      long timeLimit = ourTimeLimit;
-      final boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode();
-      WorkingTimeMeasurer measurer = new WorkingTimeMeasurer(timeLimit);
-      int count = 0;
-      while (!queue.isEmpty()) {
-        if (count % 50 == 0 && !unitTestMode && measurer.isTimeOver()) {
-          LOG.debug("Too complex because the analysis took too long");
-          psiBlock.putUserData(TOO_EXPENSIVE_HASH, psiBlock.getText().hashCode());
-          return RunnerResult.TOO_COMPLEX;
-        }
-        ProgressManager.checkCanceled();
-
-        DfaInstructionState instructionState = queue.remove(0);
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(instructionState.toString());
-        }
-
-        Instruction instruction = instructionState.getInstruction();
-        long distance = instructionState.getDistanceFromStart();
-
-        if (instruction instanceof BranchingInstruction) {
-          if (!instruction.setMemoryStateProcessed(instructionState.getMemoryState().createCopy())) {
-            LOG.debug("Too complex because too many different possible states");
-            return RunnerResult.TOO_COMPLEX; // Too complex :(
-          }
-        }
-
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(instructionState.toString());
-        }
-
-        DfaInstructionState[] after = instruction.accept(this, instructionState.getMemoryState(), visitor);
-        if (after != null) {
-          for (DfaInstructionState state : after) {
-            Instruction nextInstruction = state.getInstruction();
-            if ((!(nextInstruction instanceof BranchingInstruction) || !nextInstruction.isMemoryStateProcessed(state.getMemoryState())) && instruction.getIndex() < endOffset) {
-              state.setDistanceFromStart(distance + 1);
-              queue.add(state);
-            }
-          }
-        }
-
-        count++;
-      }
-
-      psiBlock.putUserData(TOO_EXPENSIVE_HASH, null);
-      LOG.debug("Analysis ok");
-      return RunnerResult.OK;
-    }
-    catch (ArrayIndexOutOfBoundsException e) {
-      LOG.error(psiBlock.getText(), e); // TODO fix in better times
-      return RunnerResult.ABORTED;
-    }
-    catch (EmptyStackException e) {
-      if (LOG.isDebugEnabled()) {
-        LOG.error(e); // TODO fix in better times
-      }
-      return RunnerResult.ABORTED;
-    }
-  }
-
-  protected ControlFlowAnalyzer createControlFlowAnalyzer() {
-    return new ControlFlowAnalyzer(myValueFactory);
-  }
-
-  protected DfaMemoryState createMemoryState() {
-    return new DfaMemoryStateImpl(myValueFactory);
-  }
-
-  public Instruction[] getInstructions() {
-    return myInstructions;
-  }
-
-  public DfaVariableValue[] getFields() {
-    return myFields;
-  }
-
-  public Pair<Set<Instruction>,Set<Instruction>> getConstConditionalExpressions() {
-    Set<Instruction> trueSet = new HashSet<Instruction>();
-    Set<Instruction> falseSet = new HashSet<Instruction>();
-
-    for (Instruction instruction : myInstructions) {
-      if (instruction instanceof BranchingInstruction) {
-        BranchingInstruction branchingInstruction = (BranchingInstruction)instruction;
-        if (branchingInstruction.getPsiAnchor() != null && branchingInstruction.isConditionConst()) {
-          if (!branchingInstruction.isTrueReachable()) {
-            falseSet.add(branchingInstruction);
-          }
-
-          if (!branchingInstruction.isFalseReachable()) {
-            trueSet.add(branchingInstruction);
-          }
-        }
-      }
-    }
-
-    for (Instruction instruction : myInstructions) {
-      if (instruction instanceof BranchingInstruction) {
-        BranchingInstruction branchingInstruction = (BranchingInstruction)instruction;
-        if (branchingInstruction.isTrueReachable()) {
-          falseSet.remove(branchingInstruction);
-        }
-        if (branchingInstruction.isFalseReachable()) {
-          trueSet.remove(branchingInstruction);
-        }
-      }
-    }
-
-    return Pair.create(trueSet, falseSet);
-  }
-
-  private static class EnvironmentalInstructionVisitor extends DelegatingInstructionVisitor {
-    private final PsiElement myClassParent;
-    private final Set<DfaMemoryState> myClosureStates = new THashSet<DfaMemoryState>();
-
-    private EnvironmentalInstructionVisitor(InstructionVisitor delegate, PsiElement classParent) {
-      super(delegate);
-      myClassParent = classParent;
-    }
-
-    @Override
-    public DfaInstructionState[] visitEmptyInstruction(EmptyInstruction instruction, DataFlowRunner runner, DfaMemoryState before) {
-      checkEnvironment(runner, before, instruction.getAnchor());
-      return super.visitEmptyInstruction(instruction, runner, before);
-    }
-
-    @Override
-    public DfaInstructionState[] visitMethodCall(MethodCallInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-      checkEnvironment(runner, memState, instruction.getCallExpression());
-      return super.visitMethodCall(instruction, runner, memState);
-    }
-
-    private void checkEnvironment(DataFlowRunner runner, DfaMemoryState memState, @Nullable PsiElement anchor) {
-      if (myClassParent == anchor) {
-        DfaMemoryStateImpl copy = (DfaMemoryStateImpl)memState.createCopy();
-        copy.flushFields(runner);
-        Set<DfaVariableValue> vars = new HashSet<DfaVariableValue>(copy.getVariableStates().keySet());
-        for (DfaVariableValue value : vars) {
-          copy.flushDependencies(value);
-        }
-
-        myClosureStates.add(copy);
-      }
-    }
-
-    @NotNull
-    public Collection<DfaMemoryState> getClosureStates() {
-      return myClosureStates;
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DelegatingInstructionVisitor.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DelegatingInstructionVisitor.java
deleted file mode 100644
index d8e3021..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DelegatingInstructionVisitor.java
+++ /dev/null
@@ -1,96 +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.dataFlow;
-
-import com.intellij.codeInspection.dataFlow.instructions.*;
-
-/**
- * @author peter
- */
-public class DelegatingInstructionVisitor extends InstructionVisitor {
-  private final InstructionVisitor myDelegate;
-
-  public DelegatingInstructionVisitor(InstructionVisitor delegate) {
-    myDelegate = delegate;
-  }
-
-  @Override
-  public DfaInstructionState[] visitAssign(AssignInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitAssign(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitInstanceof(InstanceofInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitInstanceof(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitBinop(BinopInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitBinop(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitCheckReturnValue(CheckReturnValueInstruction instruction,
-                                                     DataFlowRunner runner,
-                                                     DfaMemoryState memState) {
-    return myDelegate.visitCheckReturnValue(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitConditionalGoto(ConditionalGotoInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitConditionalGoto(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitEmptyStack(EmptyStackInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitEmptyStack(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitFieldReference(FieldReferenceInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitFieldReference(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitFlushVariable(FlushVariableInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitFlushVariable(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitMethodCall(MethodCallInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitMethodCall(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitCast(MethodCallInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitCast(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitNot(NotInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitNot(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitPush(PushInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitPush(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitTypeCast(TypeCastInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return myDelegate.visitTypeCast(instruction, runner, memState);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaInstructionState.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaInstructionState.java
deleted file mode 100644
index 87d8b8a..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaInstructionState.java
+++ /dev/null
@@ -1,58 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 28, 2002
- * Time: 9:40:01 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow;
-
-import com.intellij.codeInspection.dataFlow.instructions.Instruction;
-import org.jetbrains.annotations.NotNull;
-
-public class DfaInstructionState {
-  public static final DfaInstructionState[] EMPTY_ARRAY = new DfaInstructionState[0];
-  private final DfaMemoryState myBeforeMemoryState;
-  private final Instruction myInstruction;
-  private long myDistanceFromStart = 0;
-
-  public DfaInstructionState(@NotNull Instruction myInstruction, @NotNull DfaMemoryState myBeforeMemoryState) {
-    this.myBeforeMemoryState = myBeforeMemoryState;
-    this.myInstruction = myInstruction;
-  }
-
-  public long getDistanceFromStart() { return myDistanceFromStart; }
-
-  public void setDistanceFromStart(long distanceFromStart) { myDistanceFromStart = distanceFromStart; }
-
-  @NotNull
-  public Instruction getInstruction() {
-    return myInstruction;
-  }
-
-  @NotNull
-  public DfaMemoryState getMemoryState() {
-    return myBeforeMemoryState;
-  }
-
-  public String toString() {
-    return getInstruction().getIndex() + " " + getInstruction() + ":   " + getMemoryState().toString();
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryState.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryState.java
deleted file mode 100644
index 8117a7a..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryState.java
+++ /dev/null
@@ -1,61 +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.dataFlow;
-
-import com.intellij.codeInspection.dataFlow.value.DfaRelationValue;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jul 16, 2003
- * Time: 10:25:44 PM
- * To change this template use Options | File Templates.
- */
-public interface DfaMemoryState {
-  DfaMemoryState createCopy();
-
-  DfaValue pop();
-  DfaValue peek();
-  void push(@NotNull DfaValue value);
-
-  int popOffset();
-  void pushOffset(int offset);
-
-  void emptyStack();
-
-  void setVarValue(DfaVariableValue var, DfaValue value);
-
-  boolean applyInstanceofOrNull(DfaRelationValue dfaCond);
-
-  boolean applyCondition(DfaValue dfaCond);
-
-  boolean applyNotNull(DfaValue value);
-
-  void flushFields(DataFlowRunner runner);
-
-  void flushVariable(DfaVariableValue variable);
-
-  boolean isNull(DfaValue dfaVar);
-
-  boolean checkNotNullable(DfaValue value);
-
-  boolean isNotNull(DfaVariableValue dfaVar);
-
-  void flushVariableOutOfScope(DfaVariableValue variable);
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java
deleted file mode 100644
index bb30b78..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java
+++ /dev/null
@@ -1,882 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 28, 2002
- * Time: 9:39:36 PM
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow;
-
-import com.intellij.codeInspection.dataFlow.value.*;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.JavaTokenType;
-import com.intellij.psi.PsiPrimitiveType;
-import com.intellij.psi.PsiType;
-import com.intellij.psi.util.TypeConversionUtil;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.Stack;
-import gnu.trove.*;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.*;
-
-
-public class DfaMemoryStateImpl implements DfaMemoryState {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.DfaMemoryStateImpl");
-  private final DfaValueFactory myFactory;
-
-  private final ArrayList<SortedIntSet> myEqClasses = new ArrayList<SortedIntSet>();
-  private int myStateSize = 0;
-  private final Stack<DfaValue> myStack = new Stack<DfaValue>();
-  private TIntStack myOffsetStack = new TIntStack(1);
-  private final TLongHashSet myDistinctClasses = new TLongHashSet();
-  private final THashMap<DfaVariableValue,DfaVariableState> myVariableStates = new THashMap<DfaVariableValue, DfaVariableState>();
-
-  public DfaMemoryStateImpl(final DfaValueFactory factory) {
-    myFactory = factory;
-  }
-
-  public DfaValueFactory getFactory() {
-    return myFactory;
-  }
-
-  protected DfaMemoryStateImpl createNew() {
-    return new DfaMemoryStateImpl(myFactory);
-  }
-
-  @Override
-  public DfaMemoryStateImpl createCopy() {
-    DfaMemoryStateImpl newState = createNew();
-
-    //noinspection unchecked
-    newState.myStack.addAll(myStack);
-    newState.myDistinctClasses.addAll(myDistinctClasses.toArray());
-    newState.myStateSize = myStateSize;
-    newState.myOffsetStack = new TIntStack(myOffsetStack);
-
-    for (int i = 0; i < myEqClasses.size(); i++) {
-      SortedIntSet aClass = myEqClasses.get(i);
-      newState.myEqClasses.add(aClass != null ? new SortedIntSet(aClass.toNativeArray()) : null);
-    }
-
-    for (DfaVariableValue dfaVariableValue : myVariableStates.keySet()) {
-      newState.myVariableStates.put(dfaVariableValue, myVariableStates.get(dfaVariableValue).clone());
-    }
-    return newState;
-  }
-
-  public boolean equals(Object obj) {
-    if (obj == this) return true;
-    if (!(obj instanceof DfaMemoryStateImpl)) return false;
-    DfaMemoryStateImpl that = (DfaMemoryStateImpl)obj;
-
-    if (myStateSize != that.myStateSize) return false;
-    if (myDistinctClasses.size() != that.myDistinctClasses.size()) return false;
-
-    if (!myStack.equals(that.myStack)) return false;
-    if (!myOffsetStack.equals(that.myOffsetStack)) return false;
-    if (!myVariableStates.equals(that.myVariableStates)) return false;
-
-    int[] permutation = getPermutationToSortedState();
-    int[] thatPermutation = that.getPermutationToSortedState();
-
-    for (int i = 0; i < myStateSize; i++) {
-      SortedIntSet thisClass = myEqClasses.get(permutation[i]);
-      SortedIntSet thatClass = that.myEqClasses.get(thatPermutation[i]);
-      if (thisClass == null) break;
-      if (thisClass.compareTo(thatClass) != 0) return false;
-    }
-
-    long[] pairs = getSortedDistinctClasses(permutation);
-    long[] thatPairs = that.getSortedDistinctClasses(thatPermutation);
-
-    for (int i = 0; i < pairs.length; i++) {
-      if (pairs[i] != thatPairs[i]) {
-        return false;
-      }
-    }
-
-    return true;
-  }
-
-  private long[] getSortedDistinctClasses(int[] permutation) {
-    long[] pairs = myDistinctClasses.toArray();
-    for (int i = 0; i < pairs.length; i++) {
-      pairs[i] = convert(pairs[i], permutation);
-    }
-    Arrays.sort(pairs);
-    return pairs;
-  }
-
-  private long convert(long pair, int[] permutation) {
-    if (myEqClasses.get(low(pair)) == null || myEqClasses.get(high(pair)) == null) {
-      return -1L;
-    }
-    return createPair(inversePermutation(permutation, low(pair)), inversePermutation(permutation, high(pair)));
-  }
-
-  private static int inversePermutation(int[] permutation, int idx) {
-    for (int i = 0; i < permutation.length; i++) {
-      if (idx == permutation[i]) return i;
-    }
-    return -1;
-  }
-
-  private int[] getPermutationToSortedState() {
-    int size = myEqClasses.size();
-    int[] permutation = ArrayUtil.newIntArray(size);
-    for (int i = 0; i < size; i++) {
-      permutation[i] = i;
-    }
-
-    for (int i = 0; i < permutation.length; i++) {
-      for (int j = i + 1; j < permutation.length; j++) {
-        if (compare(permutation[i], permutation[j]) > 0) {
-          int t = permutation[i];
-          permutation[i] = permutation[j];
-          permutation[j] = t;
-        }
-      }
-    }
-
-    return permutation;
-  }
-
-  private int compare(int i1, int i2) {
-    SortedIntSet s1 = myEqClasses.get(i1);
-    SortedIntSet s2 = myEqClasses.get(i2);
-    if (s1 == null && s2 == null) return 0;
-    if (s1 == null) return 1;
-    if (s2 == null) return -1;
-    return s1.compareTo(s2);
-  }
-
-  public int hashCode() {
-    return 0;
-    //return myEqClasses.hashCode() + myStack.hashCode() + myVariableStates.hashCode();
-  }
-
-  private void appendClass(StringBuffer buf, int aClassIndex) {
-    SortedIntSet aClass = myEqClasses.get(aClassIndex);
-    if (aClass != null) {
-      buf.append("(");
-
-      for (int i = 0; i < aClass.size(); i++) {
-        if (i > 0) buf.append(", ");
-        int value = aClass.get(i);
-        DfaValue dfaValue = myFactory.getValue(value);
-        buf.append(dfaValue);
-      }
-      buf.append(")");
-    }
-  }
-
-  @SuppressWarnings({"HardCodedStringLiteral"})
-  public String toString() {
-    StringBuffer result = new StringBuffer();
-    result.append('<');
-
-    for (int i = 0; i < myEqClasses.size(); i++) {
-      appendClass(result, i);
-    }
-
-    result.append(" distincts: ");
-    List<String> distincs = new ArrayList<String>();
-    long[] dclasses = myDistinctClasses.toArray();
-    for (long pair : dclasses) {
-      StringBuffer one = new StringBuffer();
-      one.append("{");
-      appendClass(one, low(pair));
-      one.append(", ");
-      appendClass(one, high(pair));
-      one.append("}");
-      distincs.add(one.toString());
-    }
-    Collections.sort(distincs);
-    result.append(StringUtil.join(distincs, " "));
-
-    result.append(" stack: ").append(StringUtil.join(myStack, ","));
-    result.append(" vars: ");
-    for (Map.Entry<DfaVariableValue, DfaVariableState> entry : myVariableStates.entrySet()) {
-      result.append("[").append(entry.getKey()).append("->").append(entry.getValue()).append("]");
-    }
-    result.append('>');
-    return result.toString();
-  }
-
-  @Override
-  public DfaValue pop() {
-    return myStack.pop();
-  }
-
-  @Override
-  public DfaValue peek() {
-    return myStack.peek();
-  }
-
-  @Override
-  public void push(@NotNull DfaValue value) {
-    myStack.push(value);
-  }
-
-  @Override
-  public int popOffset() {
-    return myOffsetStack.pop();
-  }
-
-  @Override
-  public void pushOffset(int offset) {
-    myOffsetStack.push(offset);
-  }
-
-  @Override
-  public void emptyStack() {
-    myStack.clear();
-  }
-
-  @Override
-  public void setVarValue(DfaVariableValue var, DfaValue value) {
-    if (var == value) return;
-
-    flushVariable(var);
-    if (value instanceof DfaUnknownValue) {
-      getVariableState(var).setNullable(false);
-      return;
-    }
-
-    getVariableState(var).setValue(value);
-    if (value instanceof DfaNotNullValue) {
-      DfaTypeValue dfaType = myFactory.getTypeFactory().create(((DfaNotNullValue)value).getType());
-      DfaRelationValue dfaInstanceof = myFactory.getRelationFactory().createRelation(var, dfaType, JavaTokenType.INSTANCEOF_KEYWORD, false);
-      applyCondition(dfaInstanceof);
-      applyCondition(compareToNull(var, true));
-    }
-    else if (value instanceof DfaTypeValue) {
-      getVariableState(var).setNullable(((DfaTypeValue)value).isNullable());
-      DfaRelationValue dfaInstanceof = myFactory.getRelationFactory().createRelation(var, value, JavaTokenType.INSTANCEOF_KEYWORD, false);
-      applyInstanceofOrNull(dfaInstanceof);
-    }
-    else {
-      DfaRelationValue dfaEqual = myFactory.getRelationFactory().createRelation(var, value, JavaTokenType.EQEQ, false);
-      if (dfaEqual == null) return;
-      applyCondition(dfaEqual);
-
-      if (value instanceof DfaVariableValue) {
-        myVariableStates.put(var, getVariableState((DfaVariableValue)value).clone());
-      }
-    }
-
-    if (getVariableState(var).isNotNull()) {
-      applyCondition(compareToNull(var, true));
-    }
-  }
-
-  @Nullable("for boxed values which can't be compared by ==")
-  private Integer getOrCreateEqClassIndex(DfaValue dfaValue) {
-    int i = getEqClassIndex(dfaValue);
-    if (i != -1) return i;
-    if (!canBeReused(dfaValue) && !(((DfaBoxedValue)dfaValue).getWrappedValue() instanceof DfaConstValue)) {
-      return null;
-    }
-    SortedIntSet aClass = new SortedIntSet();
-    aClass.add(dfaValue.getID());
-    myEqClasses.add(aClass);
-    myStateSize++;
-
-    return myEqClasses.size() - 1;
-  }
-
-  @NotNull
-  private List<DfaValue> getEqClassesFor(@NotNull DfaValue dfaValue) {
-    int index = getEqClassIndex(dfaValue);
-    SortedIntSet set = index == -1 ? null : myEqClasses.get(index);
-    if (set == null) {
-      return Collections.emptyList();
-    }
-    final List<DfaValue> result = new ArrayList<DfaValue>(set.size());
-    set.forEach(new TIntProcedure() {
-      @Override
-      public boolean execute(int c1) {
-        DfaValue value = myFactory.getValue(c1);
-        result.add(value);
-        return true;
-      }
-    });
-    return result;
-  }
-
-  private boolean canBeNaN(@NotNull DfaValue dfaValue) {
-    for (DfaValue eq : getEqClassesFor(dfaValue)) {
-      if (eq instanceof DfaBoxedValue) {
-        eq = ((DfaBoxedValue)eq).getWrappedValue();
-      }
-      if (eq instanceof DfaConstValue && !isNaN(eq)) {
-        return false;
-      }
-    }
-
-    return dfaValue instanceof DfaVariableValue && TypeConversionUtil.isFloatOrDoubleType(((DfaVariableValue)dfaValue).getVariableType());
-  }
-
-
-  private boolean isEffectivelyNaN(@NotNull DfaValue dfaValue) {
-    for (DfaValue eqClass : getEqClassesFor(dfaValue)) {
-      if (isNaN(eqClass)) return true;
-    }
-    return false;
-  }
-
-  private int getEqClassIndex(@NotNull DfaValue dfaValue) {
-    for (int i = 0; i < myEqClasses.size(); i++) {
-      SortedIntSet aClass = myEqClasses.get(i);
-      if (aClass != null && aClass.contains(dfaValue.getID())) {
-        if (!canBeReused(dfaValue) && aClass.size() > 1) return -1;
-        return i;
-      }
-    }
-    return -1;
-  }
-
-  private boolean canBeReused(final DfaValue dfaValue) {
-    if (dfaValue instanceof DfaBoxedValue) {
-      DfaValue valueToWrap = ((DfaBoxedValue)dfaValue).getWrappedValue();
-      if (valueToWrap instanceof DfaConstValue) {
-        return cacheable((DfaConstValue)valueToWrap);
-      }
-      if (valueToWrap instanceof DfaVariableValue) {
-        if (PsiType.BOOLEAN.equals(((DfaVariableValue)valueToWrap).getVariableType())) return true;
-        for (DfaValue value : getEqClassesFor(valueToWrap)) {
-          if (value instanceof DfaConstValue && cacheable((DfaConstValue)value)) return true;
-        }
-      }
-      return false;
-    }
-    return true;
-  }
-
-  private static boolean cacheable(DfaConstValue dfaConstValue) {
-    Object value = dfaConstValue.getValue();
-    return box(value) == box(value);
-  }
-
-  @SuppressWarnings({"UnnecessaryBoxing"})
-  private static Object box(final Object value) {
-    Object newBoxedValue;
-    if (value instanceof Integer) {
-      newBoxedValue = Integer.valueOf(((Integer)value).intValue());
-    }
-    else if (value instanceof Byte) {
-      newBoxedValue = Byte.valueOf(((Byte)value).byteValue());
-    }
-    else if (value instanceof Short) {
-      newBoxedValue = Short.valueOf(((Short)value).shortValue());
-    }
-    else if (value instanceof Long) {
-      newBoxedValue = Long.valueOf(((Long)value).longValue());
-    }
-    else if (value instanceof Boolean) {
-      newBoxedValue = Boolean.valueOf(((Boolean)value).booleanValue());
-    }
-    else if (value instanceof Character) {
-      newBoxedValue = Character.valueOf(((Character)value).charValue());
-    }
-    else {
-      return new Object();
-    }
-    return newBoxedValue;
-  }
-
-  private boolean uniteClasses(int c1Index, int c2Index) {
-    SortedIntSet c1 = myEqClasses.get(c1Index);
-    SortedIntSet c2 = myEqClasses.get(c2Index);
-
-    Set<DfaVariableValue> vars = ContainerUtil.newTroveSet();
-    Set<DfaVariableValue> negatedVars = ContainerUtil.newTroveSet();
-    int[] cs = new int[c1.size() + c2.size()];
-    c1.set(0, cs, 0, c1.size());
-    c2.set(0, cs, c1.size(), c2.size());
-
-    int nConst = 0;
-    for (int c : cs) {
-      DfaValue dfaValue = myFactory.getValue(c);
-      if (dfaValue instanceof DfaBoxedValue) dfaValue = ((DfaBoxedValue)dfaValue).getWrappedValue();
-      if (dfaValue instanceof DfaUnboxedValue) dfaValue = ((DfaUnboxedValue)dfaValue).getVariable();
-      if (dfaValue instanceof DfaConstValue) nConst++;
-      if (dfaValue instanceof DfaVariableValue) {
-        DfaVariableValue variableValue = (DfaVariableValue)dfaValue;
-        if (variableValue.isNegated()) {
-          negatedVars.add(variableValue.createNegated());
-        } else {
-          vars.add(variableValue);
-        }
-      }
-      if (nConst > 1) return false;
-    }
-    if (ContainerUtil.intersects(vars, negatedVars)) return false;
-
-    TLongArrayList c2Pairs = new TLongArrayList();
-    long[] distincts = myDistinctClasses.toArray();
-    for (long distinct : distincts) {
-      int pc1 = low(distinct);
-      int pc2 = high(distinct);
-      boolean addedToC1 = false;
-
-      if (pc1 == c1Index || pc2 == c1Index) {
-        addedToC1 = true;
-      }
-
-      if (pc1 == c2Index || pc2 == c2Index) {
-        if (addedToC1) return false;
-        c2Pairs.add(distinct);
-      }
-    }
-
-    for (int i = 0; i < c2.size(); i++) {
-      int c = c2.get(i);
-      c1.add(c);
-    }
-
-    for (int i = 0; i < c2Pairs.size(); i++) {
-      long c = c2Pairs.get(i);
-      myDistinctClasses.remove(c);
-      myDistinctClasses.add(createPair(c1Index, low(c) == c2Index ? high(c) : low(c)));
-    }
-    myEqClasses.set(c2Index, null);
-    myStateSize--;
-
-    return true;
-  }
-
-  private static int low(long l) {
-    return (int)l;
-  }
-
-  private static int high(long l) {
-    return (int)((l & 0xFFFFFFFF00000000L) >> 32);
-  }
-
-  private static long createPair(int i1, int i2) {
-    if (i1 < i2) {
-      long l = i1;
-      l <<= 32;
-      l += i2;
-      return l;
-    }
-    else {
-      long l = i2;
-      l <<= 32;
-      l += i1;
-      return l;
-    }
-  }
-
-  private void makeClassesDistinct(int c1Index, int c2Index) {
-    myDistinctClasses.add(createPair(c1Index, c2Index));
-  }
-
-  @Override
-  public boolean isNull(DfaValue dfaValue) {
-    if (dfaValue instanceof DfaNotNullValue) return false;
-
-    if (dfaValue instanceof DfaVariableValue || dfaValue instanceof DfaConstValue) {
-      DfaConstValue dfaNull = myFactory.getConstFactory().getNull();
-      Integer c1Index = getOrCreateEqClassIndex(dfaValue);
-      Integer c2Index = getOrCreateEqClassIndex(dfaNull);
-
-      return c1Index != null && c1Index.equals(c2Index);
-    }
-
-    return false;
-  }
-
-  @Override
-  public boolean isNotNull(DfaVariableValue dfaVar) {
-    if (getVariableState(dfaVar).isNotNull()) {
-      return true;
-    }
-
-    DfaConstValue dfaNull = myFactory.getConstFactory().getNull();
-    Integer c1Index = getOrCreateEqClassIndex(dfaVar);
-    Integer c2Index = getOrCreateEqClassIndex(dfaNull);
-    if (c1Index == null || c2Index == null) {
-      return false;
-    }
-
-    long[] pairs = myDistinctClasses.toArray();
-    for (long pair : pairs) {
-      if (c1Index.equals(low(pair)) && c2Index.equals(high(pair)) ||
-          c1Index.equals(high(pair)) && c2Index.equals(low(pair))) {
-        return true;
-      }
-    }
-
-    return false;
-  }
-
-  @Override
-  public boolean applyInstanceofOrNull(DfaRelationValue dfaCond) {
-    DfaValue left = dfaCond.getLeftOperand();
-    if (left instanceof DfaBoxedValue) {
-      left = ((DfaBoxedValue)left).getWrappedValue();
-    }
-    else if (left instanceof DfaUnboxedValue) {
-      left = ((DfaUnboxedValue)left).getVariable();
-    }
-
-    if (!(left instanceof DfaVariableValue)) return true;
-
-    DfaVariableValue dfaVar = (DfaVariableValue)left;
-    DfaTypeValue dfaType = (DfaTypeValue)dfaCond.getRightOperand();
-
-    final DfaVariableState varState = getVariableState(dfaVar);
-    return isNull(dfaVar) || varState.setInstanceofValue(dfaType);
-  }
-
-  @Override
-  public boolean applyCondition(DfaValue dfaCond) {
-    if (dfaCond instanceof DfaUnknownValue) return true;
-    if (dfaCond instanceof DfaUnboxedValue) {
-      DfaVariableValue dfaVar = ((DfaUnboxedValue)dfaCond).getVariable();
-      boolean isNegated = dfaVar.isNegated();
-      DfaVariableValue dfaNormalVar = isNegated ? dfaVar.createNegated() : dfaVar;
-      final DfaValue boxedTrue = myFactory.getBoxedFactory().createBoxed(myFactory.getConstFactory().getTrue());
-      return applyRelationCondition(myFactory.getRelationFactory().createRelation(dfaNormalVar, boxedTrue, JavaTokenType.EQEQ, isNegated));
-    }
-    if (dfaCond instanceof DfaVariableValue) {
-      DfaVariableValue dfaVar = (DfaVariableValue)dfaCond;
-      boolean isNegated = dfaVar.isNegated();
-      DfaVariableValue dfaNormalVar = isNegated ? dfaVar.createNegated() : dfaVar;
-      DfaConstValue dfaTrue = myFactory.getConstFactory().getTrue();
-      return applyRelationCondition(myFactory.getRelationFactory().createRelation(dfaNormalVar, dfaTrue, JavaTokenType.EQEQ, isNegated));
-    }
-
-    if (dfaCond instanceof DfaConstValue) {
-      return dfaCond == myFactory.getConstFactory().getTrue() || dfaCond != myFactory.getConstFactory().getFalse();
-    }
-
-    if (!(dfaCond instanceof DfaRelationValue)) return true;
-
-    return applyRelationCondition((DfaRelationValue)dfaCond);
-  }
-
-  private boolean applyRelationCondition(DfaRelationValue dfaRelation) {
-    DfaValue dfaLeft = dfaRelation.getLeftOperand();
-    DfaValue dfaRight = dfaRelation.getRightOperand();
-    if (dfaRight == null || dfaLeft == null) return false;
-
-    boolean isNegated = dfaRelation.isNegated();
-    if (dfaLeft instanceof DfaNotNullValue && dfaRight == myFactory.getConstFactory().getNull()) {
-      return isNegated;
-    }
-
-    if (dfaRight instanceof DfaTypeValue) {
-      if (dfaLeft instanceof DfaVariableValue) {
-        DfaVariableState varState = getVariableState((DfaVariableValue)dfaLeft);
-        DfaVariableValue dfaVar = (DfaVariableValue)dfaLeft;
-        if (isNegated) {
-          return varState.addNotInstanceofValue((DfaTypeValue)dfaRight) || applyCondition(compareToNull(dfaVar, false));
-        }
-        return applyCondition(compareToNull(dfaVar, true)) && varState.setInstanceofValue((DfaTypeValue)dfaRight);
-      }
-      return true;
-    }
-
-    if (dfaRight instanceof DfaNotNullValue) {
-      return true;
-    }
-
-    if (isNull(dfaRight) && compareVariableWithNull(dfaLeft) || isNull(dfaLeft) && compareVariableWithNull(dfaRight)) {
-      return isNegated;
-    }
-
-    if (dfaLeft instanceof DfaUnknownValue || dfaRight instanceof DfaUnknownValue) return true;
-
-
-    if (isEffectivelyNaN(dfaLeft) || isEffectivelyNaN(dfaRight)) {
-      applyEquivalenceRelation(dfaRelation, dfaLeft, dfaRight);
-      return isNegated;
-    }
-    if (canBeNaN(dfaLeft) || canBeNaN(dfaRight)) {
-      applyEquivalenceRelation(dfaRelation, dfaLeft, dfaRight);
-      return true;
-    }
-
-    return applyEquivalenceRelation(dfaRelation, dfaLeft, dfaRight);
-  }
-
-  private boolean compareVariableWithNull(DfaValue val) {
-    if (val instanceof DfaVariableValue) {
-      DfaVariableValue dfaVar = (DfaVariableValue)val;
-      if (isNotNull(dfaVar)) {
-        return true;
-      }
-      getVariableState(dfaVar).setNullable(true);
-    }
-    return false;
-  }
-
-  private boolean applyEquivalenceRelation(DfaRelationValue dfaRelation, DfaValue dfaLeft, DfaValue dfaRight) {
-    boolean isNegated = dfaRelation.isNonEquality();
-    if (!isNegated && !dfaRelation.isEquality()) {
-      return true;
-    }
-    if (!applyRelation(dfaLeft, dfaRight, isNegated)) {
-      return false;
-    }
-    if (!checkCompareWithBooleanLiteral(dfaLeft, dfaRight, isNegated)) {
-      return false;
-    }
-    if (dfaLeft instanceof DfaVariableValue) {
-      if (!applyUnboxedRelation((DfaVariableValue)dfaLeft, dfaRight, isNegated)) {
-        return false;
-      }
-      if (!applyBoxedRelation((DfaVariableValue)dfaLeft, dfaRight, isNegated)) {
-        return false;
-      }
-    }
-
-    return true;
-  }
-
-  private boolean applyBoxedRelation(DfaVariableValue dfaLeft, DfaValue dfaRight, boolean negated) {
-    if (!TypeConversionUtil.isPrimitiveAndNotNull(dfaLeft.getVariableType())) return true;
-
-    DfaBoxedValue.Factory boxedFactory = myFactory.getBoxedFactory();
-    DfaValue boxedLeft = boxedFactory.createBoxed(dfaLeft);
-    DfaValue boxedRight = boxedFactory.createBoxed(dfaRight);
-    return boxedLeft == null || boxedRight == null || applyRelation(boxedLeft, boxedRight, negated);
-  }
-
-  private boolean applyUnboxedRelation(DfaVariableValue dfaLeft, DfaValue dfaRight, boolean negated) {
-    PsiType type = dfaLeft.getVariableType();
-    if (!TypeConversionUtil.isPrimitiveWrapper(type)) {
-      return true;
-    }
-    if (negated && !isMaybeBoxedConstant(dfaRight)) {
-      // from the fact (wrappers are not the same) does not follow (unboxed values are not equals)
-      return true;
-    }
-
-    DfaBoxedValue.Factory boxedFactory = myFactory.getBoxedFactory();
-    return applyRelation(boxedFactory.createUnboxed(dfaLeft), boxedFactory.createUnboxed(dfaRight), negated);
-  }
-
-  private static boolean isMaybeBoxedConstant(DfaValue val) {
-    return val instanceof DfaConstValue ||
-           (val instanceof DfaBoxedValue && ((DfaBoxedValue)val).getWrappedValue() instanceof DfaConstValue);
-  }
-
-  private boolean checkCompareWithBooleanLiteral(DfaValue dfaLeft, DfaValue dfaRight, boolean negated) {
-    if (dfaRight instanceof DfaConstValue) {
-      Object constVal = ((DfaConstValue)dfaRight).getValue();
-      if (constVal instanceof Boolean) {
-        DfaConstValue negVal = myFactory.getConstFactory().createFromValue(!((Boolean)constVal).booleanValue(), PsiType.BOOLEAN);
-        if (!applyRelation(dfaLeft, negVal, !negated)) {
-          return false;
-        }
-      }
-    }
-    return true;
-  }
-
-  static boolean isNaN(final DfaValue dfa) {
-    if (dfa instanceof DfaConstValue) {
-      Object value = ((DfaConstValue)dfa).getValue();
-      if (value instanceof Double && ((Double)value).isNaN()) return true;
-      if (value instanceof Float && ((Float)value).isNaN()) return true;
-    }
-    else if (dfa instanceof DfaBoxedValue){
-      return isNaN(((DfaBoxedValue)dfa).getWrappedValue());
-    }
-    return false;
-  }
-
-  private boolean applyRelation(@NotNull final DfaValue dfaLeft, @NotNull final DfaValue dfaRight, boolean isNegated) {
-    // DfaConstValue || DfaVariableValue
-    Integer c1Index = getOrCreateEqClassIndex(dfaLeft);
-    Integer c2Index = getOrCreateEqClassIndex(dfaRight);
-    if (c1Index == null || c2Index == null) {
-      return true;
-    }
-
-    if (!isNegated) { //Equals
-      if (c1Index.equals(c2Index)) return true;
-      if (!uniteClasses(c1Index, c2Index)) return false;
-    }
-    else { // Not Equals
-      if (c1Index.equals(c2Index)) return false;
-      makeClassesDistinct(c1Index, c2Index);
-    }
-
-    return true;
-  }
-
-  @Override
-  public boolean checkNotNullable(DfaValue value) {
-    if (value == myFactory.getConstFactory().getNull()) return false;
-    if (value instanceof DfaTypeValue && ((DfaTypeValue)value).isNullable()) return false;
-
-    if (value instanceof DfaVariableValue) {
-      if (isNotNull((DfaVariableValue)value)) return true;
-      final DfaVariableState varState = getVariableState((DfaVariableValue)value);
-      if (varState.isNullable()) return false;
-    }
-    return true;
-  }
-
-  @Override
-  public boolean applyNotNull(DfaValue value) {
-    if (value instanceof DfaVariableValue && ((DfaVariableValue)value).getVariableType() instanceof PsiPrimitiveType) {
-      return true;
-    }
-
-    return checkNotNullable(value) && applyCondition(compareToNull(value, true));
-  }
-
-  @Nullable
-  private DfaRelationValue compareToNull(DfaValue dfaVar, boolean negated) {
-    DfaConstValue dfaNull = myFactory.getConstFactory().getNull();
-    return myFactory.getRelationFactory().createRelation(dfaVar, dfaNull, JavaTokenType.EQEQ, negated);
-  }
-
-  public DfaVariableState getVariableState(DfaVariableValue dfaVar) {
-    DfaVariableState state = myVariableStates.get(dfaVar);
-
-    if (state == null) {
-      state = createVariableState(dfaVar);
-      myVariableStates.put(dfaVar, state);
-      PsiType type = dfaVar.getVariableType();
-      if (type != null) {
-        state.setInstanceofValue(myFactory.getTypeFactory().create(type));
-      }
-    }
-
-    return state;
-  }
-
-  protected Map<DfaVariableValue, DfaVariableState> getVariableStates() {
-    return myVariableStates;
-  }
-
-  protected DfaVariableState createVariableState(final DfaVariableValue var) {
-    return new DfaVariableState(var);
-  }
-
-  @Override
-  public void flushFields(DataFlowRunner runner) {
-    for (DfaVariableValue field : runner.getFields()) {
-      if (myVariableStates.containsKey(field) || getEqClassIndex(field) >= 0) {
-        if (!DfaUtil.isFinalField(field.getPsiVariable())) {
-          flushVariable(field);
-          getVariableState(field).setNullable(false);
-        }
-      }
-    }
-  }
-
-  @Override
-  public void flushVariable(@NotNull DfaVariableValue variable) {
-    doFlush(variable);
-    flushDependencies(variable);
-  }
-
-  @Override
-  public void flushVariableOutOfScope(DfaVariableValue variable) {
-    flushVariable(variable);
-  }
-
-  public void flushDependencies(DfaVariableValue variable) {
-    for (DfaVariableValue dependent : myFactory.getVarFactory().getAllQualifiedBy(variable)) {
-      doFlush(dependent);
-    }
-  }
-
-  private void doFlush(DfaVariableValue varPlain) {
-    DfaVariableValue varNegated = varPlain.createNegated();
-
-    final int idPlain = varPlain.getID();
-    final int idNegated = varNegated.getID();
-
-    int size = myEqClasses.size();
-    int interruptCount = 0;
-    for (int varClassIndex = 0; varClassIndex < size; varClassIndex++) {
-      final SortedIntSet varClass = myEqClasses.get(varClassIndex);
-      if (varClass == null) continue;
-
-      for (int i = 0; i < varClass.size(); i++) {
-        if ((++interruptCount & 0xf) == 0) {
-          ProgressManager.checkCanceled();
-        }
-        int cl = varClass.get(i);
-        DfaValue value = myFactory.getValue(cl);
-        if (mine(idPlain, value) || mine(idNegated, value)) {
-          varClass.remove(i);
-          break;
-        }
-      }
-
-      if (varClass.isEmpty()) {
-        myEqClasses.set(varClassIndex, null);
-        myStateSize--;
-        long[] pairs = myDistinctClasses.toArray();
-        for (long pair : pairs) {
-          if (low(pair) == varClassIndex || high(pair) == varClassIndex) {
-            myDistinctClasses.remove(pair);
-          }
-        }
-      }
-      else if (containsConstantsOnly(varClassIndex)) {
-        for (long pair : myDistinctClasses.toArray()) {
-          if (low(pair) == varClassIndex && containsConstantsOnly(high(pair)) ||
-              high(pair) == varClassIndex && containsConstantsOnly(low(pair))) {
-            myDistinctClasses.remove(pair);
-          }
-        }
-      }
-    }
-
-    myVariableStates.remove(varPlain);
-    myVariableStates.remove(varNegated);
-  }
-
-  private boolean containsConstantsOnly(int id) {
-    SortedIntSet varClass = myEqClasses.get(id);
-    for (int i = 0; i < varClass.size(); i++) {
-      int cl = varClass.get(i);
-      DfaValue value = myFactory.getValue(cl);
-      if (!(value instanceof DfaConstValue) &&
-          !(value instanceof DfaBoxedValue && ((DfaBoxedValue)value).getWrappedValue() instanceof DfaConstValue)) {
-        return false;
-      }
-    }
-
-    return true;
-  }
-
-  private static boolean mine(int id, DfaValue value) {
-    return value != null && id == value.getID() ||
-        value instanceof DfaBoxedValue && ((DfaBoxedValue)value).getWrappedValue().getID() == id ||
-        value instanceof DfaUnboxedValue && ((DfaUnboxedValue)value).getVariable().getID() == id;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java
deleted file mode 100644
index 9529296..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java
+++ /dev/null
@@ -1,379 +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.dataFlow;
-
-import com.intellij.codeInsight.NullableNotNullManager;
-import com.intellij.codeInspection.dataFlow.instructions.AssignInstruction;
-import com.intellij.codeInspection.dataFlow.instructions.Instruction;
-import com.intellij.codeInspection.dataFlow.instructions.PushInstruction;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
-import com.intellij.codeInspection.nullable.NullableStuffInspection;
-import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.MultiValuesMap;
-import com.intellij.openapi.util.Ref;
-import com.intellij.psi.*;
-import com.intellij.psi.search.LocalSearchScope;
-import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.psi.tree.IElementType;
-import com.intellij.psi.util.CachedValue;
-import com.intellij.psi.util.CachedValueProvider;
-import com.intellij.psi.util.CachedValuesManager;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.NullableFunction;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.Stack;
-import gnu.trove.THashSet;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.*;
-
-/**
- * @author Gregory.Shrago
- */
-public class DfaUtil {
-  private static final Key<CachedValue<MultiValuesMap<PsiVariable, PsiExpression>>> DFA_VARIABLE_INFO_KEY = Key.create("DFA_VARIABLE_INFO_KEY");
-
-  private DfaUtil() {
-  }
-
-  private static final MultiValuesMap<PsiVariable, PsiExpression> TOO_COMPLEX = new MultiValuesMap<PsiVariable, PsiExpression>();
-  @Nullable("null means DFA analysis has failed (too complex to analyze)")
-  public static Collection<PsiExpression> getCachedVariableValues(@Nullable final PsiVariable variable, @Nullable final PsiElement context) {
-    if (variable == null || context == null) return Collections.emptyList();
-
-    CachedValue<MultiValuesMap<PsiVariable, PsiExpression>> cachedValue = context.getUserData(DFA_VARIABLE_INFO_KEY);
-    if (cachedValue == null) {
-      final PsiElement codeBlock = getEnclosingCodeBlock(variable, context);
-      cachedValue = CachedValuesManager.getManager(context.getProject()).createCachedValue(new CachedValueProvider<MultiValuesMap<PsiVariable, PsiExpression>>() {
-        @Override
-        public Result<MultiValuesMap<PsiVariable, PsiExpression>> compute() {
-          final MultiValuesMap<PsiVariable, PsiExpression> result;
-          if (codeBlock == null) {
-            result = null;
-          }
-          else {
-            final ValuableInstructionVisitor visitor = new ValuableInstructionVisitor(context);
-            RunnerResult runnerResult = new ValuableDataFlowRunner().analyzeMethod(codeBlock, visitor);
-            if (runnerResult == RunnerResult.OK) {
-              result = visitor.myValues;
-            }
-            else {
-              result = TOO_COMPLEX;
-            }
-          }
-          return new Result<MultiValuesMap<PsiVariable, PsiExpression>>(result, codeBlock);
-        }
-      }, false);
-      context.putUserData(DFA_VARIABLE_INFO_KEY, cachedValue);
-    }
-    final MultiValuesMap<PsiVariable, PsiExpression> value = cachedValue.getValue();
-    if (value == TOO_COMPLEX) return null;
-    final Collection<PsiExpression> expressions = value == null ? null : value.get(variable);
-    return expressions == null ? Collections.<PsiExpression>emptyList() : expressions;
-  }
-
-  @NotNull
-  public static Nullness getElementNullability(@Nullable PsiType resultType, @Nullable PsiModifierListOwner owner) {
-    if (owner == null) {
-      return Nullness.UNKNOWN;
-    }
-
-    if (NullableNotNullManager.isNullable(owner)) {
-      return Nullness.NULLABLE;
-    }
-    if (NullableNotNullManager.isNotNull(owner)) {
-      return Nullness.NOT_NULL;
-    }
-
-    if (resultType != null) {
-      NullableNotNullManager nnn = NullableNotNullManager.getInstance(owner.getProject());
-      for (PsiAnnotation annotation : resultType.getAnnotations()) {
-        String qualifiedName = annotation.getQualifiedName();
-        if (nnn.getNullables().contains(qualifiedName)) {
-          return Nullness.NULLABLE;
-        }
-        if (nnn.getNotNulls().contains(qualifiedName)) {
-          return Nullness.NOT_NULL;
-        }
-      }
-    }
-
-    return Nullness.UNKNOWN;
-  }
-
-  public static boolean isNullableInitialized(PsiVariable var, boolean nullable) {
-    if (!isFinalField(var)) {
-      return false;
-    }
-
-    List<PsiExpression> initializers = NullableStuffInspection.findAllConstructorInitializers((PsiField)var);
-    if (initializers.isEmpty()) {
-      return false;
-    }
-
-    for (PsiExpression expression : initializers) {
-      if (!(expression instanceof PsiReferenceExpression)) {
-        return false;
-      }
-      PsiElement target = ((PsiReferenceExpression)expression).resolve();
-      if (!(target instanceof PsiParameter)) {
-        return false;
-      }
-      if (nullable && NullableNotNullManager.isNullable((PsiParameter)target)) {
-        return true;
-      }
-      if (!nullable && !NullableNotNullManager.isNotNull((PsiParameter)target)) {
-        return false;
-      }
-    }
-    return !nullable;
-  }
-
-  public static boolean isPlainMutableField(PsiVariable var) {
-    return !var.hasModifierProperty(PsiModifier.FINAL) && !var.hasModifierProperty(PsiModifier.TRANSIENT) && !var.hasModifierProperty(PsiModifier.VOLATILE) && var instanceof PsiField;
-  }
-
-  public static boolean isFinalField(PsiVariable var) {
-    return var.hasModifierProperty(PsiModifier.FINAL) && !var.hasModifierProperty(PsiModifier.TRANSIENT) && var instanceof PsiField;
-  }
-
-  @NotNull
-  public static Nullness checkNullness(@Nullable final PsiVariable variable, @Nullable final PsiElement context) {
-    if (variable == null || context == null) return Nullness.UNKNOWN;
-
-    final PsiElement codeBlock = getEnclosingCodeBlock(variable, context);
-    if (codeBlock == null) {
-      return Nullness.UNKNOWN;
-    }
-    final ValuableInstructionVisitor visitor = new ValuableInstructionVisitor(context);
-    RunnerResult result = new ValuableDataFlowRunner().analyzeMethod(codeBlock, visitor);
-    if (result != RunnerResult.OK) {
-      return Nullness.UNKNOWN;
-    }
-    if (visitor.myNulls.contains(variable) && !visitor.myNotNulls.contains(variable)) return Nullness.NULLABLE;
-    if (visitor.myNotNulls.contains(variable) && !visitor.myNulls.contains(variable)) return Nullness.NOT_NULL;
-    return Nullness.UNKNOWN;
-  }
-
-  @Nullable
-  public static PsiCodeBlock getTopmostBlockInSameClass(@NotNull PsiElement position) {
-    PsiCodeBlock block = PsiTreeUtil.getParentOfType(position, PsiCodeBlock.class, false, PsiMember.class, PsiFile.class);
-    if (block == null) {
-      return null;
-    }
-
-    PsiCodeBlock lastBlock = block;
-    while (true) {
-      block = PsiTreeUtil.getParentOfType(block, PsiCodeBlock.class, true, PsiMember.class, PsiFile.class);
-      if (block == null) {
-        return lastBlock;
-      }
-      lastBlock = block;
-    }
-  }
-
-  private static PsiElement getEnclosingCodeBlock(final PsiVariable variable, final PsiElement context) {
-    PsiElement codeBlock;
-    if (variable instanceof PsiParameter) {
-      codeBlock = ((PsiParameter)variable).getDeclarationScope();
-      if (codeBlock instanceof PsiMethod) {
-        codeBlock = ((PsiMethod)codeBlock).getBody();
-      }
-    }
-    else if (variable instanceof PsiLocalVariable) {
-      codeBlock = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
-    }
-    else {
-      codeBlock = PsiTreeUtil.getParentOfType(context, PsiCodeBlock.class);
-    }
-    while (codeBlock != null) {
-      PsiAnonymousClass anon = PsiTreeUtil.getParentOfType(codeBlock, PsiAnonymousClass.class);
-      if (anon == null) break;
-      codeBlock = PsiTreeUtil.getParentOfType(anon, PsiCodeBlock.class);
-    }
-    return codeBlock;
-  }
-
-  @NotNull
-  public static Collection<? extends PsiElement> getPossibleInitializationElements(final PsiElement qualifierExpression) {
-    if (qualifierExpression instanceof PsiMethodCallExpression) {
-      return Collections.singletonList(qualifierExpression);
-    }
-    if (qualifierExpression instanceof PsiReferenceExpression) {
-      final PsiElement targetElement = ((PsiReferenceExpression)qualifierExpression).resolve();
-      if (!(targetElement instanceof PsiVariable)) {
-        return Collections.emptyList();
-      }
-      final Collection<? extends PsiElement> variableValues = getCachedVariableValues((PsiVariable)targetElement, qualifierExpression);
-      if (variableValues == null || variableValues.isEmpty()) {
-        return getVariableAssignmentsInFile((PsiVariable)targetElement, false, qualifierExpression);
-      }
-      return variableValues;
-    }
-    if (qualifierExpression instanceof PsiLiteralExpression) {
-      return Collections.singletonList(qualifierExpression);
-    }
-    return Collections.emptyList();
-  }
-
-  @NotNull
-  public static Collection<PsiExpression> getVariableAssignmentsInFile(final PsiVariable psiVariable,
-                                                                       final boolean literalsOnly,
-                                                                       final PsiElement place) {
-    final Ref<Boolean> modificationRef = Ref.create(Boolean.FALSE);
-    final PsiCodeBlock codeBlock = place == null? null : getTopmostBlockInSameClass(place);
-    final int placeOffset = codeBlock != null? place.getTextRange().getStartOffset() : 0;
-    final List<PsiExpression> list = ContainerUtil.mapNotNull(
-      ReferencesSearch.search(psiVariable, new LocalSearchScope(new PsiElement[] {psiVariable.getContainingFile()}, null, true)).findAll(),
-      new NullableFunction<PsiReference, PsiExpression>() {
-        @Override
-        public PsiExpression fun(final PsiReference psiReference) {
-          if (modificationRef.get()) return null;
-          final PsiElement parent = psiReference.getElement().getParent();
-          if (parent instanceof PsiAssignmentExpression) {
-            final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)parent;
-            final IElementType operation = assignmentExpression.getOperationTokenType();
-            if (assignmentExpression.getLExpression() == psiReference) {
-              if (JavaTokenType.EQ.equals(operation)) {
-                final PsiExpression rValue = assignmentExpression.getRExpression();
-                if (!literalsOnly || allOperandsAreLiterals(rValue)) {
-                  // if there's a codeBlock omit the values assigned later
-                  if (codeBlock != null && PsiTreeUtil.isAncestor(codeBlock, parent, true)
-                      && placeOffset < parent.getTextRange().getStartOffset()) {
-                    return null;
-                  }
-                  return rValue;
-                }
-                else {
-                  modificationRef.set(Boolean.TRUE);
-                }
-              }
-              else if (JavaTokenType.PLUSEQ.equals(operation)) {
-                modificationRef.set(Boolean.TRUE);
-              }
-            }
-          }
-          return null;
-        }
-      });
-    if (modificationRef.get()) return Collections.emptyList();
-    if (!literalsOnly || allOperandsAreLiterals(psiVariable.getInitializer())) {
-      ContainerUtil.addIfNotNull(psiVariable.getInitializer(), list);
-    }
-    return list;
-  }
-
-  public static boolean allOperandsAreLiterals(@Nullable final PsiExpression expression) {
-    if (expression == null) return false;
-    if (expression instanceof PsiLiteralExpression) return true;
-    if (expression instanceof PsiPolyadicExpression) {
-      Stack<PsiExpression> stack = new Stack<PsiExpression>();
-      stack.add(expression);
-      while (!stack.isEmpty()) {
-        PsiExpression psiExpression = stack.pop();
-        if (psiExpression instanceof PsiPolyadicExpression) {
-          PsiPolyadicExpression binaryExpression = (PsiPolyadicExpression)psiExpression;
-          for (PsiExpression op : binaryExpression.getOperands()) {
-            stack.push(op);
-          }
-        }
-        else if (!(psiExpression instanceof PsiLiteralExpression)) {
-          return false;
-        }
-      }
-      return true;
-    }
-    return false;
-  }
-
-  private static class ValuableInstructionVisitor extends StandardInstructionVisitor {
-    final MultiValuesMap<PsiVariable, PsiExpression> myValues = new MultiValuesMap<PsiVariable, PsiExpression>(true);
-    final Set<PsiVariable> myNulls = new THashSet<PsiVariable>();
-    final Set<PsiVariable> myNotNulls = new THashSet<PsiVariable>();
-    private final PsiElement myContext;
-
-    public ValuableInstructionVisitor(@NotNull PsiElement context) {
-      myContext = context;
-    }
-
-    @Override
-    public DfaInstructionState[] visitPush(PushInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-      if (myContext == instruction.getPlace()) {
-        final Map<DfaVariableValue,DfaVariableState> map = ((ValuableDataFlowRunner.MyDfaMemoryState)memState).getVariableStates();
-        for (Map.Entry<DfaVariableValue, DfaVariableState> entry : map.entrySet()) {
-          ValuableDataFlowRunner.ValuableDfaVariableState state = (ValuableDataFlowRunner.ValuableDfaVariableState)entry.getValue();
-          DfaVariableValue variableValue = entry.getKey();
-          final PsiExpression psiExpression = state.myExpression;
-          if (psiExpression != null && variableValue.getQualifier() == null) {
-            myValues.put(variableValue.getPsiVariable(), psiExpression);
-          }
-        }
-        DfaValue value = instruction.getValue();
-        if (value instanceof DfaVariableValue && ((DfaVariableValue)value).getQualifier() == null) {
-          if (memState.isNotNull((DfaVariableValue)value)) {
-            myNotNulls.add(((DfaVariableValue)value).getPsiVariable());
-          }
-          if (memState.isNull(value)) {
-            myNulls.add(((DfaVariableValue)value).getPsiVariable());
-          }
-        }
-      }
-      return super.visitPush(instruction, runner, memState);
-    }
-
-    @Override
-    public DfaInstructionState[] visitAssign(AssignInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-      final Instruction nextInstruction = runner.getInstruction(instruction.getIndex() + 1);
-
-      final DfaValue dfaSource = memState.pop();
-      final DfaValue dfaDest = memState.pop();
-
-      if (dfaDest instanceof DfaVariableValue) {
-        DfaVariableValue var = (DfaVariableValue)dfaDest;
-        final PsiExpression rightValue = instruction.getRExpression();
-        final PsiElement parent = rightValue == null ? null : rightValue.getParent();
-        final IElementType type = parent instanceof PsiAssignmentExpression
-                                  ? ((PsiAssignmentExpression)parent).getOperationTokenType() : JavaTokenType.EQ;
-        // store current value - to use in case of '+='
-        final PsiExpression prevValue = ((ValuableDataFlowRunner.ValuableDfaVariableState)((ValuableDataFlowRunner.MyDfaMemoryState)memState).getVariableState(var)).myExpression;
-        memState.setVarValue(var, dfaSource);
-        // state may have been changed so re-retrieve it
-        final ValuableDataFlowRunner.ValuableDfaVariableState curState = (ValuableDataFlowRunner.ValuableDfaVariableState)((ValuableDataFlowRunner.MyDfaMemoryState)memState).getVariableState(var);
-        final PsiExpression curValue = curState.myExpression;
-        final PsiExpression nextValue;
-        if (type == JavaTokenType.PLUSEQ && prevValue != null) {
-          PsiExpression tmpExpression;
-          try {
-            tmpExpression = JavaPsiFacade.getElementFactory(myContext.getProject())
-              .createExpressionFromText(prevValue.getText() + "+" + rightValue.getText(), rightValue);
-          }
-          catch (Exception e) {
-            tmpExpression = curValue == null ? rightValue : curValue;
-          }
-          nextValue = tmpExpression;
-        }
-        else {
-          nextValue = curValue == null ? rightValue : curValue;
-        }
-        curState.myExpression = nextValue;
-      }
-      memState.push(dfaDest);
-      return new DfaInstructionState[]{new DfaInstructionState(nextInstruction, memState)};
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaVariableState.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaVariableState.java
deleted file mode 100644
index cbbe164..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaVariableState.java
+++ /dev/null
@@ -1,157 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Feb 3, 2002
- * Time: 9:49:29 PM
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow;
-
-import com.intellij.codeInspection.dataFlow.value.DfaTypeValue;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
-import com.intellij.psi.*;
-import gnu.trove.THashSet;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-public class DfaVariableState implements Cloneable {
-  private final Set<DfaTypeValue> myInstanceofValues;
-  private final Set<DfaTypeValue> myNotInstanceofValues;
-  private Nullness myNullability;
-
-  public DfaVariableState(@NotNull DfaVariableValue dfaVar) {
-    myInstanceofValues = new HashSet<DfaTypeValue>();
-    myNotInstanceofValues = new HashSet<DfaTypeValue>();
-
-    myNullability = dfaVar.getInherentNullability();
-  }
-
-  protected DfaVariableState(final DfaVariableState toClone) {
-    myInstanceofValues = new THashSet<DfaTypeValue>(toClone.myInstanceofValues);
-    myNotInstanceofValues = new THashSet<DfaTypeValue>(toClone.myNotInstanceofValues);
-    myNullability = toClone.myNullability;
-  }
-
-  public boolean isNullable() {
-    return myNullability == Nullness.NULLABLE;
-  }
-
-  private boolean checkInstanceofValue(DfaTypeValue dfaType) {
-    if (myInstanceofValues.contains(dfaType)) return true;
-
-    for (DfaTypeValue dfaTypeValue : myNotInstanceofValues) {
-      if (dfaTypeValue.isAssignableFrom(dfaType)) return false;
-    }
-
-    for (DfaTypeValue dfaTypeValue : myInstanceofValues) {
-      if (!dfaType.isConvertibleFrom(dfaTypeValue)) return false;
-    }
-
-    return true;
-  }
-
-  public boolean setInstanceofValue(DfaTypeValue dfaType) {
-    if (dfaType.isNullable()) {
-      myNullability = Nullness.NULLABLE;
-    }
-
-    if (dfaType.getType() instanceof PsiPrimitiveType) return true;
-
-    if (checkInstanceofValue(dfaType)) {
-      myInstanceofValues.add(dfaType);
-      return true;
-    }
-
-    return false;
-  }
-
-  public boolean addNotInstanceofValue(DfaTypeValue dfaType) {
-    if (myNotInstanceofValues.contains(dfaType)) return true;
-
-    for (DfaTypeValue dfaTypeValue : myInstanceofValues) {
-      if (dfaType.isAssignableFrom(dfaTypeValue)) return false;
-    }
-
-    myNotInstanceofValues.add(dfaType);
-    return true;
-  }
-
-  public int hashCode() {
-    return myInstanceofValues.hashCode() + myNotInstanceofValues.hashCode();
-  }
-
-  public boolean equals(Object obj) {
-    if (obj == this) return true;
-    if (!(obj instanceof DfaVariableState)) return false;
-    DfaVariableState aState = (DfaVariableState) obj;
-    return myInstanceofValues.equals(aState.myInstanceofValues) &&
-           myNotInstanceofValues.equals(aState.myNotInstanceofValues) &&
-           myNullability == aState.myNullability;
-  }
-
-  @Override
-  protected DfaVariableState clone() {
-    return new DfaVariableState(this);
-  }
-
-  public String toString() {
-    @NonNls StringBuilder buf = new StringBuilder();
-
-    buf.append("instanceof ");
-    for (Iterator<DfaTypeValue> iterator = myInstanceofValues.iterator(); iterator.hasNext();) {
-      DfaTypeValue dfaTypeValue = iterator.next();
-      buf.append("{").append(dfaTypeValue).append("}");
-      if (iterator.hasNext()) buf.append(", ");
-    }
-
-    buf.append("not instanceof ");
-    for (Iterator<DfaTypeValue> iterator = myNotInstanceofValues.iterator(); iterator.hasNext();) {
-      DfaTypeValue dfaTypeValue = iterator.next();
-      buf.append("{").append(dfaTypeValue).append("}");
-      if (iterator.hasNext()) buf.append(", ");
-    }
-    buf.append(", nullable=").append(myNullability);
-    return buf.toString();
-  }
-
-  public boolean isNotNull() {
-    return myNullability == Nullness.NOT_NULL;
-  }
-
-  public void setNullable(final boolean nullable) {
-    if (myNullability != Nullness.NOT_NULL) {
-      myNullability = nullable ? Nullness.NULLABLE : Nullness.UNKNOWN;
-    }
-  }
-
-  public void setValue(DfaValue value) {
-  }
-
-  @Nullable
-  public DfaValue getValue() {
-    return null;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/InstructionVisitor.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/InstructionVisitor.java
deleted file mode 100644
index 6d8d8d6..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/InstructionVisitor.java
+++ /dev/null
@@ -1,164 +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.dataFlow;
-
-import com.intellij.codeInspection.dataFlow.instructions.*;
-import com.intellij.codeInspection.dataFlow.value.DfaUnknownValue;
-import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-import com.intellij.psi.PsiExpression;
-
-import java.util.ArrayList;
-
-/**
- * @author peter
- */
-public abstract class InstructionVisitor {
-
-  public DfaInstructionState[] visitAssign(AssignInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    memState.pop();
-    memState.push(memState.pop());
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  protected static DfaInstructionState[] nextInstruction(Instruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return new DfaInstructionState[]{new DfaInstructionState(runner.getInstruction(instruction.getIndex() + 1), memState)};
-  }
-
-  public DfaInstructionState[] visitInstanceof(InstanceofInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return visitBinop(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitBinop(BinopInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    memState.pop();
-    memState.pop();
-    memState.push(DfaUnknownValue.getInstance());
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitCheckReturnValue(CheckReturnValueInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    memState.pop();
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitConditionalGoto(ConditionalGotoInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    DfaValue cond = memState.pop();
-
-    DfaValue condTrue;
-    DfaValue condFalse;
-
-    if (instruction.isNegated()) {
-      condFalse = cond;
-      condTrue = cond.createNegated();
-    } else {
-      condTrue = cond;
-      condFalse = cond.createNegated();
-    }
-
-    if (condTrue == runner.getFactory().getConstFactory().getTrue()) {
-      markBranchReachable(instruction, true);
-      return new DfaInstructionState[] {new DfaInstructionState(runner.getInstruction(instruction.getOffset()), memState)};
-    }
-
-    if (condFalse == runner.getFactory().getConstFactory().getTrue()) {
-      markBranchReachable(instruction, false);
-      return nextInstruction(instruction, runner, memState);
-    }
-
-    ArrayList<DfaInstructionState> result = new ArrayList<DfaInstructionState>();
-
-    DfaMemoryState thenState = memState.createCopy();
-    DfaMemoryState elseState = memState.createCopy();
-
-    if (thenState.applyCondition(condTrue)) {
-      result.add(new DfaInstructionState(runner.getInstruction(instruction.getOffset()), thenState));
-      markBranchReachable(instruction, true);
-    }
-
-    if (elseState.applyCondition(condFalse)) {
-      result.add(new DfaInstructionState(runner.getInstruction(instruction.getIndex() + 1), elseState));
-      markBranchReachable(instruction, false);
-    }
-
-    return result.toArray(new DfaInstructionState[result.size()]);
-  }
-
-  private static void markBranchReachable(ConditionalGotoInstruction instruction, boolean isTrueBranch) {
-    if (isTrueBranch ^ instruction.isNegated()) {
-      instruction.setTrueReachable();
-    }
-    else {
-      instruction.setFalseReachable();
-    }
-  }
-
-
-  public DfaInstructionState[] visitEmptyStack(EmptyStackInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    memState.emptyStack();
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitFieldReference(FieldReferenceInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    memState.pop();
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitFlushVariable(FlushVariableInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    final DfaVariableValue variable = instruction.getVariable();
-    if (variable != null) {
-      memState.flushVariableOutOfScope(variable);
-    } else {
-      memState.flushFields(runner);
-    }
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitMethodCall(MethodCallInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    //noinspection UnusedDeclaration
-    for (PsiExpression arg : instruction.getArgs()) {
-      memState.pop();
-    }
-
-    memState.pop(); //qualifier
-    memState.push(DfaUnknownValue.getInstance());
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitCast(MethodCallInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return visitMethodCall(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitNot(NotInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    DfaValue dfaValue = memState.pop();
-
-    dfaValue = dfaValue.createNegated();
-    memState.push(dfaValue);
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitPush(PushInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    memState.push(instruction.getValue());
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitTypeCast(TypeCastInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  public DfaInstructionState[] visitEmptyInstruction(EmptyInstruction instruction, DataFlowRunner runner, DfaMemoryState before) {
-    return nextInstruction(instruction, runner, before);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/MethodCheckerDetailsDialog.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/MethodCheckerDetailsDialog.java
index 154ad18..008ae77 100644
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/MethodCheckerDetailsDialog.java
+++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/MethodCheckerDetailsDialog.java
@@ -39,17 +39,17 @@
  * Dialog that appears when the user clicks the Add Button or double clicks a row item in a MethodsPanel.  The MethodsPanel is accessed from the ConditionCheckDialog
  */
 class MethodCheckerDetailsDialog extends DialogWrapper implements PropertyChangeListener, ItemListener {
-  private final @NotNull ConditionChecker.Type myType;
-  private final @NotNull Project myProject;
-  private final @NotNull ParameterDropDown parameterDropDown;
-  private final @NotNull MethodDropDown methodDropDown;
-  private final @NotNull ClassField classField;
-  private final @NotNull Set<ConditionChecker> myOtherCheckers;
-  private final @Nullable ConditionChecker myPreviouslySelectedChecker;
+  @NotNull private final ConditionChecker.Type myType;
+  @NotNull private final Project myProject;
+  @NotNull private final ParameterDropDown parameterDropDown;
+  @NotNull private final MethodDropDown methodDropDown;
+  @NotNull private final ClassField classField;
+  @NotNull private final Set<ConditionChecker> myOtherCheckers;
+  @Nullable private final ConditionChecker myPreviouslySelectedChecker;
   /**
    * Set by the OK and/or Cancel actions so that the caller can retrieve it via a call to getMethodIsNullIsNotNullChecker
    */
-  private @Nullable ConditionChecker mySelectedChecker;
+  @Nullable private ConditionChecker mySelectedChecker;
 
   MethodCheckerDetailsDialog(@Nullable ConditionChecker previouslySelectedChecker,
                              @NotNull ConditionChecker.Type type,
@@ -263,8 +263,8 @@
    */
   static class ClassField extends EditorTextFieldWithBrowseButton implements ActionListener, DocumentListener {
     public static final String PROPERTY_PSICLASS = "ClassField.myPsiClass";
-    private final @NotNull Project myProject;
-    private @Nullable PsiClass myPsiClass;
+    @NotNull private final Project myProject;
+    @Nullable private PsiClass myPsiClass;
 
     public ClassField(@NotNull Project project, @Nullable PsiClass psiClass) {
       super(project, true, buildVisibilityChecker());
@@ -341,9 +341,9 @@
    * Drop Down for picking Method Name
    */
   static class MethodDropDown extends JComboBox implements PropertyChangeListener {
-    private final @NotNull ConditionChecker.Type myType;
-    private final @NotNull SortedComboBoxModel<MethodWrapper> myModel;
-    private @Nullable PsiClass myPsiClass;
+    @NotNull private final ConditionChecker.Type myType;
+    @NotNull private final SortedComboBoxModel<MethodWrapper> myModel;
+    @Nullable private PsiClass myPsiClass;
 
     MethodDropDown(@Nullable PsiClass psiClass,
                    @Nullable PsiMethod psiMethod,
@@ -478,9 +478,9 @@
    * Drop Down for picking Parameter Name
    */
   static class ParameterDropDown extends JComboBox implements PropertyChangeListener, ItemListener {
-    private final @NotNull SortedComboBoxModel<ParameterWrapper> myModel;
-    private final @NotNull ConditionChecker.Type myType;
-    private @Nullable PsiMethod myPsiMethod;
+    @NotNull private final SortedComboBoxModel<ParameterWrapper> myModel;
+    @NotNull private final ConditionChecker.Type myType;
+    @Nullable private PsiMethod myPsiMethod;
 
     public ParameterDropDown(@Nullable PsiMethod psiMethod,
                              @Nullable PsiParameter psiParameter,
@@ -582,8 +582,8 @@
     }
 
     class ParameterWrapper implements Comparable<ParameterWrapper> {
-      private final @NotNull String id;
-      private final @NotNull PsiParameter psiParameter;
+      @NotNull private final String id;
+      @NotNull private final PsiParameter psiParameter;
       private final int index;
 
       ParameterWrapper(@NotNull PsiParameter psiParameter, int index) {
@@ -624,8 +624,8 @@
   }
 
   static class MethodWrapper implements Comparable<MethodWrapper> {
-    private final @NotNull PsiMethod myPsiMethod;
-    private final @NotNull String myId;
+    @NotNull private final PsiMethod myPsiMethod;
+    @NotNull private final String myId;
 
     MethodWrapper(@NotNull PsiMethod psiMethod) {
       this.myPsiMethod = psiMethod;
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/Nullness.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/Nullness.java
deleted file mode 100644
index 3dd099b..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/Nullness.java
+++ /dev/null
@@ -1,23 +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.dataFlow;
-
-/**
-* @author cdr
-*/
-public enum Nullness {
-  NOT_NULL, NULLABLE,UNKNOWN
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/RunnerResult.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/RunnerResult.java
deleted file mode 100644
index 67cdb47..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/RunnerResult.java
+++ /dev/null
@@ -1,27 +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.
- */
-
-/*
- * @author max
- */
-package com.intellij.codeInspection.dataFlow;
-
-public enum RunnerResult {
-  OK,
-  TOO_COMPLEX,
-  NOT_APPLICABLE,
-  ABORTED
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/SortedIntSet.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/SortedIntSet.java
deleted file mode 100644
index ae3075f..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/SortedIntSet.java
+++ /dev/null
@@ -1,71 +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.dataFlow;
-
-import gnu.trove.TIntArrayList;
-
-/**
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Aug 3, 2003
- * Time: 6:16:20 PM
- * To change this template use Options | File Templates.
- */
-public class SortedIntSet extends TIntArrayList implements Comparable<SortedIntSet> {
-  public SortedIntSet() {
-  }
-
-  public SortedIntSet(int[] values) {
-    super(values);
-  }
-
-  @Override
-  public void add(int val) {
-    for(int idx = 0; idx < size(); idx++) {
-      int data = get(idx);
-      if (data == val) return;
-      if (data > val) {
-        insert(idx, val);
-        return;
-      }
-    }
-    super.add(val);
-  }
-
-  @Override
-  public void add(int[] vals) {
-    for (int val : vals) {
-      add(val);
-    }
-  }
-
-  public void removeValue(int val) {
-    int offset = indexOf(val);
-    if (offset != -1) {
-      remove(offset);
-    }
-  }
-
-  @Override
-  public int compareTo(SortedIntSet t) {
-    if (t == this) return 0;
-    if (t.size() != size()) return size() - t.size();
-    for (int i = 0; i < size(); i++) {
-      if (_data[i] != t._data[i]) return _data[i] - t._data[i];
-    }
-    return 0;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/StandardDataFlowRunner.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/StandardDataFlowRunner.java
deleted file mode 100644
index 442a334..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/StandardDataFlowRunner.java
+++ /dev/null
@@ -1,177 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 28, 2002
- * Time: 10:16:39 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow;
-
-import com.intellij.codeInsight.NullableNotNullManager;
-import com.intellij.codeInspection.dataFlow.instructions.InstanceofInstruction;
-import com.intellij.codeInspection.dataFlow.instructions.Instruction;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.Pair;
-import com.intellij.psi.*;
-import gnu.trove.THashSet;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-public class StandardDataFlowRunner extends AnnotationsAwareDataFlowRunner {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.DataFlowRunner");
-
-  private final Set<Instruction> myNPEInstructions = new HashSet<Instruction>();
-  private final Set<Instruction> myCCEInstructions = new HashSet<Instruction>();
-  private final Set<PsiExpression> myNullableArguments = new HashSet<PsiExpression>();
-  private final Set<PsiExpression> myNullableArgumentsPassedToNonAnnotatedParam = new HashSet<PsiExpression>();
-  private final Set<PsiExpression> myNullableAssignments = new HashSet<PsiExpression>();
-  private final Set<PsiReturnStatement> myNullableReturns = new HashSet<PsiReturnStatement>();
-
-  private final boolean mySuggestNullableAnnotations;
-  private boolean myInNullableMethod = false;
-  private boolean myInNotNullMethod = false;
-  private boolean myIsInMethod = false;
-
-  private final Set<PsiExpression> myUnboxedNullables = new THashSet<PsiExpression>();
-
-  public StandardDataFlowRunner(boolean suggestNullableAnnotations) {
-    mySuggestNullableAnnotations = suggestNullableAnnotations;
-  }
-
-  @Override
-  protected Collection<DfaMemoryState> createInitialStates(@NotNull PsiElement psiBlock, InstructionVisitor visitor) {
-    final Collection<DfaMemoryState> initialStates = super.createInitialStates(psiBlock, visitor);
-
-    myIsInMethod = psiBlock.getParent() instanceof PsiMethod;
-    if (myIsInMethod) {
-      PsiMethod method = (PsiMethod)psiBlock.getParent();
-      PsiType returnType = method.getReturnType();
-      myInNullableMethod = NullableNotNullManager.isNullable(method) ||
-                           returnType != null && returnType.equalsToText(CommonClassNames.JAVA_LANG_VOID);
-      myInNotNullMethod = NullableNotNullManager.isNotNull(method);
-    }
-
-    myNPEInstructions.clear();
-    myCCEInstructions.clear();
-    myNullableArguments.clear();
-    myNullableArgumentsPassedToNonAnnotatedParam.clear();
-    myNullableAssignments.clear();
-    myNullableReturns.clear();
-    myUnboxedNullables.clear();
-
-    return initialStates;
-  }
-
-  public void onInstructionProducesNPE(Instruction instruction) {
-    myNPEInstructions.add(instruction);
-  }
-
-  public void onInstructionProducesCCE(Instruction instruction) {
-    myCCEInstructions.add(instruction);
-  }
-
-  @NotNull public Set<Instruction> getCCEInstructions() {
-    return myCCEInstructions;
-  }
-
-  @NotNull public Set<Instruction> getNPEInstructions() {
-    return myNPEInstructions;
-  }
-
-  @NotNull public Set<PsiReturnStatement> getNullableReturns() {
-    return myNullableReturns;
-  }
-
-  public boolean isInNotNullMethod() {
-    return myInNotNullMethod;
-  }
-
-  @NotNull public Set<PsiExpression> getNullableArguments() {
-    return myNullableArguments;
-  }
-
-  public Set<PsiExpression> getNullableArgumentsPassedToNonAnnotatedParam() {
-    return myNullableArgumentsPassedToNonAnnotatedParam;
-  }
-
-  @NotNull public Set<PsiExpression> getNullableAssignments() {
-    return myNullableAssignments;
-  }
-
-  @NotNull public Set<PsiExpression> getUnboxedNullables() {
-    return myUnboxedNullables;
-  }
-
-  public void onUnboxingNullable(@NotNull PsiExpression expression) {
-    LOG.assertTrue(expression.isValid());
-    if (expression.isPhysical()) {
-      myUnboxedNullables.add(expression);
-    }
-  }
-
-  public void onPassingNullParameter(PsiExpression expr) {
-    myNullableArguments.add(expr);
-  }
-
-  public void onPassingNullParameterToNonAnnotated(PsiExpression expr) {
-    if (mySuggestNullableAnnotations) {
-      myNullableArgumentsPassedToNonAnnotatedParam.add(expr);
-    }
-  }
-
-  public void onAssigningToNotNullableVariable(final PsiExpression expr) {
-    myNullableAssignments.add(expr);
-  }
-
-  public void onNullableReturn(final PsiReturnStatement statement) {
-    if (myInNullableMethod || !myIsInMethod) return;
-    if (myInNotNullMethod || mySuggestNullableAnnotations) {
-      myNullableReturns.add(statement);
-    }
-  }
-
-  public boolean problemsDetected(StandardInstructionVisitor visitor) {
-    final Pair<Set<Instruction>, Set<Instruction>> constConditions = getConstConditionalExpressions();
-    return !constConditions.getFirst().isEmpty()
-           || !constConditions.getSecond().isEmpty()
-           || !myNPEInstructions.isEmpty()
-           || !myCCEInstructions.isEmpty()
-           || !getRedundantInstanceofs(this, visitor).isEmpty()
-           || !myNullableArguments.isEmpty()
-           || !myNullableArgumentsPassedToNonAnnotatedParam.isEmpty()
-           || !myNullableAssignments.isEmpty()
-           || !myNullableReturns.isEmpty()
-           || !myUnboxedNullables.isEmpty();
-  }
-
-  @NotNull public static Set<Instruction> getRedundantInstanceofs(final DataFlowRunner runner, StandardInstructionVisitor visitor) {
-    HashSet<Instruction> result = new HashSet<Instruction>(1);
-    for (Instruction instruction : runner.getInstructions()) {
-      if (instruction instanceof InstanceofInstruction && visitor.isInstanceofRedundant((InstanceofInstruction)instruction)) {
-        result.add(instruction);
-      }
-    }
-
-    return result;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java
deleted file mode 100644
index 54df852..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java
+++ /dev/null
@@ -1,442 +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.dataFlow;
-
-import com.intellij.codeInspection.dataFlow.instructions.*;
-import com.intellij.codeInspection.dataFlow.value.*;
-import com.intellij.psi.*;
-import com.intellij.psi.tree.IElementType;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.TypeConversionUtil;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.FactoryMap;
-import gnu.trove.THashSet;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author peter
- */
-public class StandardInstructionVisitor extends InstructionVisitor {
-  private final Set<BinopInstruction> myReachable = new THashSet<BinopInstruction>();
-  private final Set<BinopInstruction> myCanBeNullInInstanceof = new THashSet<BinopInstruction>();
-  private final Set<PsiElement> myNotToReportReachability = new THashSet<PsiElement>();
-  private final Set<InstanceofInstruction> myUsefulInstanceofs = new THashSet<InstanceofInstruction>();
-  private final FactoryMap<MethodCallInstruction, Map<PsiExpression, Nullness>> myParametersNullability = new FactoryMap<MethodCallInstruction, Map<PsiExpression, Nullness>>() {
-    @Nullable
-    @Override
-    protected Map<PsiExpression, Nullness> create(MethodCallInstruction key) {
-      return calcParameterNullability(key.getCallExpression());
-    }
-  };
-  private final FactoryMap<MethodCallInstruction, Nullness> myReturnTypeNullability = new FactoryMap<MethodCallInstruction, Nullness>() {
-    @Override
-    protected Nullness create(MethodCallInstruction key) {
-      final PsiCallExpression callExpression = key.getCallExpression();
-      if (callExpression instanceof PsiNewExpression) {
-        return Nullness.NOT_NULL;
-      }
-
-      return callExpression != null ? DfaUtil.getElementNullability(key.getResultType(), callExpression.resolveMethod()) : null;
-    }
-  };
-
-  private static Map<PsiExpression, Nullness> calcParameterNullability(@Nullable PsiCallExpression callExpression) {
-    PsiExpressionList argumentList = callExpression == null ? null : callExpression.getArgumentList();
-    if (argumentList != null) {
-      JavaResolveResult result = callExpression.resolveMethodGenerics();
-      PsiMethod method = (PsiMethod)result.getElement();
-      if (method != null) {
-        PsiSubstitutor substitutor = result.getSubstitutor();
-        PsiExpression[] args = argumentList.getExpressions();
-        PsiParameter[] parameters = method.getParameterList().getParameters();
-
-        boolean varArg = isVarArgCall(method, substitutor, args, parameters);
-        int checkedCount = Math.min(args.length, parameters.length) - (varArg ? 1 : 0);
-
-        Map<PsiExpression, Nullness> map = ContainerUtil.newHashMap();
-        for (int i = 0; i < checkedCount; i++) {
-          map.put(args[i], DfaUtil.getElementNullability(substitutor.substitute(parameters[i].getType()), parameters[i]));
-        }
-        return map;
-      }
-    }
-    return Collections.emptyMap();
-  }
-
-  private static boolean isVarArgCall(PsiMethod method, PsiSubstitutor substitutor, PsiExpression[] args, PsiParameter[] parameters) {
-    if (!method.isVarArgs()) {
-      return false;
-    }
-
-    int argCount = args.length;
-    int paramCount = parameters.length;
-    if (argCount > paramCount) {
-      return true;
-    }
-    else if (paramCount > 0) {
-      if (argCount == paramCount) {
-        PsiType lastArgType = args[argCount - 1].getType();
-        if (lastArgType != null &&
-            !substitutor.substitute(parameters[paramCount - 1].getType()).isAssignableFrom(lastArgType)) {
-          return true;
-        }
-      }
-    }
-    return false;
-  }
-
-  @Override
-  public DfaInstructionState[] visitAssign(AssignInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    DfaValue dfaSource = memState.pop();
-    DfaValue dfaDest = memState.pop();
-
-    if (dfaDest instanceof DfaVariableValue) {
-      DfaVariableValue var = (DfaVariableValue) dfaDest;
-      final PsiVariable psiVariable = var.getPsiVariable();
-      if (DfaUtil.getElementNullability(var.getVariableType(), psiVariable) == Nullness.NOT_NULL) {
-        if (!memState.applyNotNull(dfaSource)) {
-          onAssigningToNotNullableVariable(instruction);
-        }
-      }
-      if (!(psiVariable instanceof PsiField) || !psiVariable.hasModifierProperty(PsiModifier.VOLATILE)) {
-        memState.setVarValue(var, dfaSource);
-      }
-    } else if (dfaDest instanceof DfaNotNullValue && !memState.applyNotNull(dfaSource)) {
-      onAssigningToNotNullableVariable(instruction);
-    }
-
-    memState.push(dfaDest);
-
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  protected void onAssigningToNotNullableVariable(AssignInstruction instruction) {}
-
-  @Override
-  public DfaInstructionState[] visitCheckReturnValue(CheckReturnValueInstruction instruction,
-                                                     DataFlowRunner runner,
-                                                     DfaMemoryState memState) {
-    final DfaValue retValue = memState.pop();
-    if (!memState.checkNotNullable(retValue)) {
-      onNullableReturn(instruction);
-    }
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  protected void onNullableReturn(CheckReturnValueInstruction instruction) {}
-
-  @Override
-  public DfaInstructionState[] visitFieldReference(FieldReferenceInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    final DfaValue qualifier = memState.pop();
-    if (instruction.getExpression().isPhysical() && !memState.applyNotNull(qualifier)) {
-      onInstructionProducesNPE(instruction);
-
-      if (qualifier instanceof DfaVariableValue) {
-        final DfaNotNullValue.Factory factory = runner.getFactory().getNotNullFactory();
-        memState.setVarValue((DfaVariableValue)qualifier, factory.create(((DfaVariableValue)qualifier).getVariableType()));
-      }
-    }
-
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  @Override
-  public DfaInstructionState[] visitTypeCast(TypeCastInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    final DfaValueFactory factory = runner.getFactory();
-    DfaValue dfaExpr = factory.createValue(instruction.getCasted());
-    if (dfaExpr != null) {
-      DfaTypeValue dfaType = factory.getTypeFactory().create(instruction.getCastTo());
-      DfaRelationValue dfaInstanceof = factory.getRelationFactory().createRelation(dfaExpr, dfaType, JavaTokenType.INSTANCEOF_KEYWORD, false);
-      if (dfaInstanceof != null && !memState.applyInstanceofOrNull(dfaInstanceof)) {
-        onInstructionProducesCCE(instruction);
-      }
-    }
-
-    if (instruction.getCastTo() instanceof PsiPrimitiveType) {
-      memState.push(runner.getFactory().getBoxedFactory().createUnboxed(memState.pop()));
-    }
-
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  protected void onInstructionProducesCCE(TypeCastInstruction instruction) {}
-
-  @Override
-  public DfaInstructionState[] visitMethodCall(MethodCallInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    final PsiExpression[] args = instruction.getArgs();
-    Map<PsiExpression, Nullness> map = myParametersNullability.get(instruction);
-    final DfaNotNullValue.Factory factory = runner.getFactory().getNotNullFactory();
-    for (int i = 0; i < args.length; i++) {
-      final DfaValue arg = memState.pop();
-      PsiExpression expr = args[(args.length - i - 1)];
-      if (map.get(expr) == Nullness.NOT_NULL) {
-        if (!memState.applyNotNull(arg)) {
-          onPassingNullParameter(expr);
-          if (arg instanceof DfaVariableValue) {
-            memState.setVarValue((DfaVariableValue)arg, factory.create(((DfaVariableValue)arg).getVariableType()));
-          }
-        }
-      }
-      else if (map.get(expr) == Nullness.UNKNOWN && !memState.checkNotNullable(arg)) {
-        onPassingNullParameterToNonAnnotated(runner, expr);
-      }
-    }
-
-    @NotNull final DfaValue qualifier = memState.pop();
-    try {
-      if (!memState.applyNotNull(qualifier)) {
-        onInstructionProducesNPE(instruction);
-        if (qualifier instanceof DfaVariableValue) {
-          memState.setVarValue((DfaVariableValue)qualifier, factory.create(((DfaVariableValue)qualifier).getVariableType()));
-        }
-      }
-
-      return nextInstruction(instruction, runner, memState);
-    }
-    finally {
-      memState.push(getMethodResultValue(instruction, qualifier, runner.getFactory()));
-      if (instruction.shouldFlushFields()) {
-        memState.flushFields(runner);
-      }
-    }
-  }
-
-  @NotNull
-  private DfaValue getMethodResultValue(MethodCallInstruction instruction, @NotNull DfaValue qualifierValue, DfaValueFactory factory) {
-    DfaValue precalculated = instruction.getPrecalculatedReturnValue();
-    if (precalculated != null) {
-      return precalculated;
-    }
-
-    final PsiType type = instruction.getResultType();
-    final MethodCallInstruction.MethodType methodType = instruction.getMethodType();
-    if (type != null && (type instanceof PsiClassType || type.getArrayDimensions() > 0)) {
-      return factory.createTypeValueWithNullability(type, myReturnTypeNullability.get(instruction));
-    }
-
-    if (methodType == MethodCallInstruction.MethodType.UNBOXING) {
-      return factory.getBoxedFactory().createUnboxed(qualifierValue);
-    }
-
-    if (methodType == MethodCallInstruction.MethodType.BOXING) {
-      DfaValue boxed = factory.getBoxedFactory().createBoxed(qualifierValue);
-      return boxed == null ? DfaUnknownValue.getInstance() : boxed;
-    }
-
-    if (methodType == MethodCallInstruction.MethodType.CAST) {
-      if (qualifierValue instanceof DfaConstValue) {
-        return factory.getConstFactory().createFromValue(castConstValue((DfaConstValue)qualifierValue), type);
-      }
-      return qualifierValue;
-    }
-    return DfaUnknownValue.getInstance();
-  }
-
-  private static Object castConstValue(DfaConstValue constValue) {
-    Object o = constValue.getValue();
-    if (o instanceof Double || o instanceof Float) {
-      double dbVal = o instanceof Double ? ((Double)o).doubleValue() : ((Float)o).doubleValue();
-      // 5.0f == 5
-      if (Math.floor(dbVal) != dbVal) {
-        return o;
-      }
-    }
-
-    return TypeConversionUtil.computeCastTo(o, PsiType.LONG);
-  }
-
-
-  protected void onInstructionProducesNPE(Instruction instruction) {}
-
-  protected void onPassingNullParameter(PsiExpression arg) {}
-  protected void onPassingNullParameterToNonAnnotated(DataFlowRunner runner, PsiExpression arg) {}
-
-  @Override
-  public DfaInstructionState[] visitBinop(BinopInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
-    myReachable.add(instruction);
-
-    DfaValue dfaRight = memState.pop();
-    DfaValue dfaLeft = memState.pop();
-
-    final IElementType opSign = instruction.getOperationSign();
-    if (opSign != null) {
-      DfaInstructionState[] states = handleConstantComparison(instruction, runner, memState, dfaRight, dfaLeft);
-      if (states == null) {
-        states = handleRelationBinop(instruction, runner, memState, dfaRight, dfaLeft);
-      }
-      if (states != null) {
-        return states;
-      }
-
-      if (JavaTokenType.PLUS == opSign) {
-        memState.push(instruction.getNonNullStringValue(runner.getFactory()));
-      }
-      else {
-        if (instruction instanceof InstanceofInstruction) {
-          handleInstanceof((InstanceofInstruction)instruction, dfaRight, dfaLeft);
-        }
-        memState.push(DfaUnknownValue.getInstance());
-      }
-    }
-    else {
-      memState.push(DfaUnknownValue.getInstance());
-    }
-
-    instruction.setTrueReachable();  // Not a branching instruction actually.
-    instruction.setFalseReachable();
-
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  @Nullable
-  private DfaInstructionState[] handleRelationBinop(BinopInstruction instruction,
-                                                    DataFlowRunner runner,
-                                                    DfaMemoryState memState,
-                                                    DfaValue dfaRight, DfaValue dfaLeft) {
-    DfaValueFactory factory = runner.getFactory();
-    final Instruction next = runner.getInstruction(instruction.getIndex() + 1);
-    DfaRelationValue dfaRelation = factory.getRelationFactory().createRelation(dfaLeft, dfaRight, instruction.getOperationSign(), false);
-    if (dfaRelation == null) {
-      return null;
-    }
-
-    if (isViaMethods(dfaLeft) || isViaMethods(dfaRight)) {
-      skipConstantConditionReporting(instruction.getPsiAnchor());
-    }
-    myCanBeNullInInstanceof.add(instruction);
-
-    ArrayList<DfaInstructionState> states = new ArrayList<DfaInstructionState>();
-
-    final DfaMemoryState trueCopy = memState.createCopy();
-    if (trueCopy.applyCondition(dfaRelation)) {
-      if (!dfaRelation.isNegated()) {
-        checkOneOperandNotNull(dfaRight, dfaLeft, factory, trueCopy);
-      }
-      trueCopy.push(factory.getConstFactory().getTrue());
-      instruction.setTrueReachable();
-      states.add(new DfaInstructionState(next, trueCopy));
-    }
-
-    //noinspection UnnecessaryLocalVariable
-    DfaMemoryState falseCopy = memState;
-    if (falseCopy.applyCondition(dfaRelation.createNegated())) {
-      if (dfaRelation.isNegated()) {
-        checkOneOperandNotNull(dfaRight, dfaLeft, factory, falseCopy);
-      }
-      falseCopy.push(factory.getConstFactory().getFalse());
-      instruction.setFalseReachable();
-      states.add(new DfaInstructionState(next, falseCopy));
-      if (instruction instanceof InstanceofInstruction && !falseCopy.isNull(dfaLeft)) {
-        myUsefulInstanceofs.add((InstanceofInstruction)instruction);
-      }
-    }
-
-    return states.toArray(new DfaInstructionState[states.size()]);
-  }
-
-  public void skipConstantConditionReporting(@Nullable PsiElement anchor) {
-    ContainerUtil.addIfNotNull(myNotToReportReachability, anchor);
-  }
-
-  private static boolean isViaMethods(DfaValue dfa) {
-    return dfa instanceof DfaVariableValue && ((DfaVariableValue)dfa).isViaMethods();
-  }
-
-  private void handleInstanceof(InstanceofInstruction instruction, DfaValue dfaRight, DfaValue dfaLeft) {
-    if ((dfaLeft instanceof DfaTypeValue || dfaLeft instanceof DfaNotNullValue) && dfaRight instanceof DfaTypeValue) {
-      final PsiType leftType;
-      if (dfaLeft instanceof DfaNotNullValue) {
-        leftType = ((DfaNotNullValue)dfaLeft).getType();
-      }
-      else {
-        leftType = ((DfaTypeValue)dfaLeft).getType();
-        myCanBeNullInInstanceof.add(instruction);
-      }
-
-      if (((DfaTypeValue)dfaRight).getType().isAssignableFrom(leftType)) {
-        return;
-      }
-    }
-    myUsefulInstanceofs.add(instruction);
-  }
-
-  @Nullable
-  private static DfaInstructionState[] handleConstantComparison(BinopInstruction instruction,
-                                                                DataFlowRunner runner,
-                                                                DfaMemoryState memState,
-                                                                DfaValue dfaRight,
-                                                                DfaValue dfaLeft) {
-    final IElementType opSign = instruction.getOperationSign();
-    if (JavaTokenType.EQEQ != opSign && JavaTokenType.NE != opSign ||
-        !(dfaLeft instanceof DfaConstValue) || !(dfaRight instanceof DfaConstValue)) {
-      return null;
-    }
-
-    boolean negated = (JavaTokenType.NE == opSign) ^ (DfaMemoryStateImpl.isNaN(dfaLeft) || DfaMemoryStateImpl.isNaN(dfaRight));
-    if (dfaLeft == dfaRight ^ negated) {
-      memState.push(runner.getFactory().getConstFactory().getTrue());
-      instruction.setTrueReachable();
-    }
-    else {
-      memState.push(runner.getFactory().getConstFactory().getFalse());
-      instruction.setFalseReachable();
-    }
-    return nextInstruction(instruction, runner, memState);
-  }
-
-  private static void checkOneOperandNotNull(DfaValue var1, DfaValue var2, DfaValueFactory factory, DfaMemoryState state) {
-    DfaValue nowNotNull = isNotNullExpression(var2, state) ? var1 : isNotNullExpression(var1, state) ? var2 : null;
-    if (nowNotNull != null) {
-      state.applyCondition(factory.getRelationFactory().createRelation(nowNotNull, factory.getConstFactory().getNull(), JavaTokenType.EQEQ, true));
-    }
-  }
-
-  private static boolean isNotNullExpression(DfaValue dfa, DfaMemoryState state) {
-    if (dfa instanceof DfaVariableValue) {
-      return state.isNotNull((DfaVariableValue)dfa);
-    }
-    if (dfa instanceof DfaConstValue) {
-      Object val = ((DfaConstValue)dfa).getValue();
-      if (val instanceof PsiEnumConstant) {
-        return true;
-      }
-    }
-    return false;
-  }
-
-  public boolean isInstanceofRedundant(InstanceofInstruction instruction) {
-    return !myUsefulInstanceofs.contains(instruction) && !instruction.isConditionConst() && myReachable.contains(instruction);
-  }
-
-  public boolean canBeNull(BinopInstruction instruction) {
-    return myCanBeNullInInstanceof.contains(instruction);
-  }
-
-  public boolean silenceConstantCondition(@Nullable PsiElement element) {
-    for (PsiElement skipped : myNotToReportReachability) {
-      if (PsiTreeUtil.isAncestor(element, skipped, false)) {
-        return true;
-      }
-    }
-    return false;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ValuableDataFlowRunner.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/ValuableDataFlowRunner.java
deleted file mode 100644
index 07752ef..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ValuableDataFlowRunner.java
+++ /dev/null
@@ -1,79 +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.dataFlow;
-
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-import com.intellij.codeInspection.dataFlow.value.DfaValueFactory;
-import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
-import com.intellij.psi.PsiExpression;
-
-/**
- * @author Gregory.Shrago
- */
-public class ValuableDataFlowRunner extends AnnotationsAwareDataFlowRunner {
-
-  @Override
-  protected DfaMemoryState createMemoryState() {
-    return new MyDfaMemoryState(getFactory());
-  }
-
-  static class MyDfaMemoryState extends DfaMemoryStateImpl {
-    private MyDfaMemoryState(final DfaValueFactory factory) {
-      super(factory);
-    }
-
-    @Override
-    protected DfaMemoryStateImpl createNew() {
-      return new MyDfaMemoryState(getFactory());
-    }
-
-    @Override
-    protected DfaVariableState createVariableState(DfaVariableValue var) {
-      return new ValuableDfaVariableState(var);
-    }
-
-  }
-
-  static class ValuableDfaVariableState extends DfaVariableState {
-    DfaValue myValue;
-    PsiExpression myExpression;
-
-    private ValuableDfaVariableState(final DfaVariableValue psiVariable) {
-      super(psiVariable);
-    }
-
-    protected ValuableDfaVariableState(final ValuableDfaVariableState state) {
-      super(state);
-      myExpression = state.myExpression;
-    }
-
-    @Override
-    public void setValue(final DfaValue value) {
-      myValue = value;
-    }
-
-    @Override
-    public DfaValue getValue() {
-      return myValue;
-    }
-
-    @Override
-    protected ValuableDfaVariableState clone() {
-      return new ValuableDfaVariableState(this);
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/WorkingTimeMeasurer.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/WorkingTimeMeasurer.java
deleted file mode 100644
index b0c4f18..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/WorkingTimeMeasurer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.dataFlow;
-
-import org.jetbrains.annotations.Nullable;
-
-import java.lang.management.ManagementFactory;
-import java.lang.management.ThreadMXBean;
-
-/**
- * @author peter
- */
-public class WorkingTimeMeasurer {
-  private final long myTimeLimit;
-  private final long myStart;
-  @Nullable private static final ThreadMXBean ourThreadMXBean;
-
-  static {
-    ThreadMXBean bean = ManagementFactory.getThreadMXBean();
-    ourThreadMXBean = bean.isCurrentThreadCpuTimeSupported() ? bean : null;
-  }
-
-  private static long getCurrentTime() {
-    return ourThreadMXBean != null ? ourThreadMXBean.getCurrentThreadUserTime() : System.nanoTime();
-  }
-
-  public WorkingTimeMeasurer(long nanoLimit) {
-    myTimeLimit = nanoLimit;
-    myStart = getCurrentTime();
-  }
-
-  public boolean isTimeOver() {
-    return getCurrentTime() - myStart > myTimeLimit;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/AssignInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/AssignInstruction.java
deleted file mode 100644
index a35195a..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/AssignInstruction.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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 26, 2002
- * Time: 10:47:33 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.psi.PsiExpression;
-
-public class AssignInstruction extends Instruction {
-  private final PsiExpression myRExpression;
-
-  public AssignInstruction(PsiExpression RExpression) {
-    myRExpression = RExpression;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitAssign(this, runner, stateBefore);
-  }
-
-  public PsiExpression getRExpression() {
-    return myRExpression;
-  }
-
-  public String toString() {
-    return "ASSIGN";
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/BinopInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/BinopInstruction.java
deleted file mode 100644
index 195f538..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/BinopInstruction.java
+++ /dev/null
@@ -1,73 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Feb 7, 2002
- * Time: 1:11:08 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-import com.intellij.codeInspection.dataFlow.value.DfaValueFactory;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.tree.IElementType;
-import com.intellij.psi.tree.TokenSet;
-import org.jetbrains.annotations.NotNull;
-
-import static com.intellij.psi.JavaTokenType.*;
-
-public class BinopInstruction extends BranchingInstruction {
-  private static final TokenSet ourSignificantOperations = TokenSet.create(EQEQ, NE, LT, GT, LE, GE, INSTANCEOF_KEYWORD, PLUS);
-  private final IElementType myOperationSign;
-  private final Project myProject;
-
-  public BinopInstruction(IElementType opSign, PsiElement psiAnchor, @NotNull Project project) {
-    myProject = project;
-    myOperationSign = ourSignificantOperations.contains(opSign) ? opSign : null;
-
-    setPsiAnchor(psiAnchor);
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitBinop(this, runner, stateBefore);
-  }
-
-  public DfaValue getNonNullStringValue(final DfaValueFactory factory) {
-    PsiElement anchor = getPsiAnchor();
-    Project project = myProject;
-    PsiClassType string = PsiType.getJavaLangString(PsiManager.getInstance(project), anchor == null ? GlobalSearchScope.allScope(project) : anchor.getResolveScope());
-    return factory.getNotNullFactory().create(string);
-  }
-
-  public String toString() {
-    return "BINOP " + myOperationSign;
-  }
-
-  public IElementType getOperationSign() {
-    return myOperationSign;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/BranchingInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/BranchingInstruction.java
deleted file mode 100644
index d1524fc..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/BranchingInstruction.java
+++ /dev/null
@@ -1,77 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Feb 8, 2002
- * Time: 10:03:49 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiLiteralExpression;
-import org.jetbrains.annotations.NonNls;
-
-public abstract class BranchingInstruction extends Instruction {
-  private boolean myIsTrueReachable;
-  private boolean myIsFalseReachable;
-  private boolean isConstTrue;
-  private PsiElement myExpression;
-
-  protected BranchingInstruction() {
-    myIsTrueReachable = false;
-    myIsFalseReachable = false;
-    setPsiAnchor(null);
-  }
-
-  public boolean isTrueReachable() {
-    return myIsTrueReachable;
-  }
-
-  public boolean isFalseReachable() {
-    return myIsFalseReachable;
-  }
-
-  public PsiElement getPsiAnchor() {
-    return myExpression;
-  }
-
-  public void setTrueReachable() {
-    myIsTrueReachable = true;
-  }
-
-  public void setFalseReachable() {
-    myIsFalseReachable = true;
-  }
-
-  public boolean isConditionConst() {
-    return !isConstTrue && myIsTrueReachable != myIsFalseReachable;
-  }
-
-  private static boolean isBoolConst(PsiElement condition) {
-    if (!(condition instanceof PsiLiteralExpression)) return false;
-    @NonNls String text = condition.getText();
-    return "true".equals(text) || "false".equals(text);
-  }
-
-  protected void setPsiAnchor(PsiElement psiAnchor) {
-    myExpression = psiAnchor;
-    isConstTrue = psiAnchor != null && isBoolConst(psiAnchor);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/CheckReturnValueInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/CheckReturnValueInstruction.java
deleted file mode 100644
index a668a7b..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/CheckReturnValueInstruction.java
+++ /dev/null
@@ -1,46 +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.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.psi.PsiReturnStatement;
-
-/**
- * @author max
- */
-public class CheckReturnValueInstruction extends Instruction {
-  private final PsiReturnStatement myReturn;
-
-  public CheckReturnValueInstruction(final PsiReturnStatement aReturn) {
-    myReturn = aReturn;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitCheckReturnValue(this, runner, stateBefore);
-  }
-
-  public PsiReturnStatement getReturn() {
-    return myReturn;
-  }
-
-  public String toString() {
-    return "CheckReturnValue";
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/ConditionalGotoInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/ConditionalGotoInstruction.java
deleted file mode 100644
index 4459c35..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/ConditionalGotoInstruction.java
+++ /dev/null
@@ -1,64 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 26, 2002
- * Time: 10:48:29 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.psi.PsiElement;
-
-public class ConditionalGotoInstruction extends BranchingInstruction {
-  private int myOffset;
-  private final boolean myIsNegated;
-
-  public ConditionalGotoInstruction(int myOffset, boolean isNegated, PsiElement psiAnchor) {
-    this.myOffset = myOffset;
-    myIsNegated = isNegated;
-    setPsiAnchor(psiAnchor);
-  }
-
-  public boolean isNegated() {
-    return myIsNegated;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitConditionalGoto(this, runner, stateBefore);
-  }
-
-  public String toString() {
-    return (isNegated() ? "!":"") + "cond?_goto " + myOffset;
-  }
-
-  public int getOffset() {
-    return myOffset;
-  }
-
-  public void setOffset(int offset) {
-    myOffset = offset;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/DupInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/DupInstruction.java
deleted file mode 100644
index ab0e969..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/DupInstruction.java
+++ /dev/null
@@ -1,41 +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.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-
-/**
- * @author max
- */
-public class DupInstruction extends Instruction {
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState memState, InstructionVisitor visitor) {
-    final DfaValue a = memState.pop();
-    memState.push(a);
-    memState.push(a);
-    Instruction nextInstruction = runner.getInstruction(getIndex() + 1);
-    return new DfaInstructionState[]{new DfaInstructionState(nextInstruction, memState)};
-  }
-
-  public String toString() {
-    return "DUP";
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/EmptyInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/EmptyInstruction.java
deleted file mode 100644
index 6605465..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/EmptyInstruction.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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 26, 2002
- * Time: 10:48:42 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.*;
-import com.intellij.psi.PsiElement;
-import org.jetbrains.annotations.Nullable;
-
-
-public class EmptyInstruction extends Instruction {
-  @Nullable private final PsiElement myAnchor;
-
-  public EmptyInstruction(@Nullable PsiElement anchor) {
-    myAnchor = anchor;
-  }
-
-  @Nullable
-  public PsiElement getAnchor() {
-    return myAnchor;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitEmptyInstruction(this, runner, stateBefore);
-  }
-
-  public String toString() {
-    return "EMPTY";
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/EmptyStackInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/EmptyStackInstruction.java
deleted file mode 100644
index 2a585af..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/EmptyStackInstruction.java
+++ /dev/null
@@ -1,39 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Mar 15, 2002
- * Time: 5:04:29 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.*;
-
-public class EmptyStackInstruction extends Instruction {
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitEmptyStack(this, runner, stateBefore);
-  }
-
-  public String toString() {
-    return "EMTY_STACK";
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/FieldReferenceInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/FieldReferenceInstruction.java
deleted file mode 100644
index a28e613..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/FieldReferenceInstruction.java
+++ /dev/null
@@ -1,62 +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.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.psi.PsiArrayAccessExpression;
-import com.intellij.psi.PsiExpression;
-import com.intellij.psi.PsiReferenceExpression;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * @author max
- */
-public class FieldReferenceInstruction extends Instruction {
-  private final PsiExpression myExpression;
-  @Nullable private final String mySyntheticFieldName;
-
-  public FieldReferenceInstruction(@NotNull PsiExpression expression, @Nullable @NonNls String syntheticFieldName) {
-    myExpression = expression;
-    mySyntheticFieldName = syntheticFieldName;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitFieldReference(this, runner, stateBefore);
-  }
-
-  public String toString() {
-    return "FIELD_REFERENCE: " + myExpression.getText();
-  }
-
-  @NotNull
-  public PsiExpression getExpression() {
-    return myExpression;
-  }
-
-  @Nullable 
-  public PsiExpression getElementToAssert() {
-    if (mySyntheticFieldName != null) return myExpression;
-    return myExpression instanceof PsiArrayAccessExpression
-           ? ((PsiArrayAccessExpression)myExpression).getArrayExpression()
-           : ((PsiReferenceExpression)myExpression).getQualifierExpression();
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/FlushVariableInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/FlushVariableInstruction.java
deleted file mode 100644
index 2214cf6..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/FlushVariableInstruction.java
+++ /dev/null
@@ -1,49 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 26, 2002
- * Time: 10:48:06 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.*;
-import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
-
-public class FlushVariableInstruction extends Instruction {
-  private final DfaVariableValue myVariable;
-
-  public FlushVariableInstruction(DfaVariableValue expr) {
-    myVariable = expr;
-  }
-
-  public DfaVariableValue getVariable() {
-    return myVariable;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitFlushVariable(this, runner, stateBefore);
-  }
-
-  public String toString() {
-    return "FLUSH " + (myVariable != null ? myVariable.toString() : " all fields");
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/GosubInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/GosubInstruction.java
deleted file mode 100644
index a36e3f8..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/GosubInstruction.java
+++ /dev/null
@@ -1,44 +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.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-
-/**
- * @author max
- */
-public class GosubInstruction extends Instruction {
-  private final int mySubprogramOffset;
-
-  public GosubInstruction(int subprogramOffset) {
-    mySubprogramOffset = subprogramOffset;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    final int returnIndex = getIndex() + 1;
-    stateBefore.pushOffset(returnIndex);
-    Instruction nextInstruction = runner.getInstruction(mySubprogramOffset);
-    return new DfaInstructionState[] {new DfaInstructionState(nextInstruction, stateBefore)};
-  }
-
-  public String toString() {
-    return "GOSUB: " + mySubprogramOffset;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/GotoInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/GotoInstruction.java
deleted file mode 100644
index 806025e..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/GotoInstruction.java
+++ /dev/null
@@ -1,54 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 26, 2002
- * Time: 10:48:19 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-
-
-public class GotoInstruction extends Instruction {
-  private int myOffset;
-
-  public GotoInstruction(int myOffset) {
-    this.myOffset = myOffset;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    Instruction nextInstruction = runner.getInstruction(myOffset);
-    return new DfaInstructionState[]{new DfaInstructionState(nextInstruction, stateBefore)};
-  }
-
-  public String toString() {
-    return "GOTO: " + myOffset;
-  }
-
-  public void setOffset(int offset) {
-    myOffset = offset;
-  }
-
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/InstanceofInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/InstanceofInstruction.java
deleted file mode 100644
index 68a8282..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/InstanceofInstruction.java
+++ /dev/null
@@ -1,53 +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.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author peter
- */
-public class InstanceofInstruction extends BinopInstruction {
-  @NotNull private final PsiExpression myLeft;
-  @NotNull private final PsiType myCastType;
-
-  public InstanceofInstruction(PsiElement psiAnchor, @NotNull Project project, PsiExpression left, PsiType castType) {
-    super(JavaTokenType.INSTANCEOF_KEYWORD, psiAnchor, project);
-    myLeft = left;
-    myCastType = castType;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitInstanceof(this, runner, stateBefore);
-  }
-
-  @NotNull
-  public PsiExpression getLeft() {
-    return myLeft;
-  }
-
-  @NotNull
-  public PsiType getCastType() {
-    return myCastType;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/Instruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/Instruction.java
deleted file mode 100644
index 505deaa..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/Instruction.java
+++ /dev/null
@@ -1,73 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 26, 2002
- * Time: 10:46:40 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.openapi.progress.ProgressManager;
-
-import java.util.ArrayList;
-
-public abstract class Instruction {
-  private int myIndex;
-  private final ArrayList<DfaMemoryState> myProcessedStates;
-
-  protected Instruction() {
-    myProcessedStates = new ArrayList<DfaMemoryState>();
-  }
-
-  protected final DfaInstructionState[] nextInstruction(DataFlowRunner runner, DfaMemoryState stateBefore) {
-    return new DfaInstructionState[] {new DfaInstructionState(runner.getInstruction(getIndex() + 1), stateBefore)};
-  }
-
-  public abstract DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor);
-
-  public boolean isMemoryStateProcessed(DfaMemoryState dfaMemState) {
-    for (DfaMemoryState state : myProcessedStates) {
-      ProgressManager.checkCanceled();
-      if (dfaMemState.equals(state)) {
-        return true;
-      }
-    }
-
-    return false;
-  }
-
-  public boolean setMemoryStateProcessed(DfaMemoryState dfaMemState) {
-    if (myProcessedStates.size() > DataFlowRunner.MAX_STATES_PER_BRANCH) return false;
-    myProcessedStates.add(dfaMemState);
-    return true;
-  }
-
-  public void setIndex(int index) {
-    myIndex = index;
-  }
-
-  public int getIndex() {
-    return myIndex;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/MethodCallInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/MethodCallInstruction.java
deleted file mode 100644
index 5f65a86..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/MethodCallInstruction.java
+++ /dev/null
@@ -1,124 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 26, 2002
- * Time: 10:48:52 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-import com.intellij.psi.*;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-
-public class MethodCallInstruction extends Instruction {
-  @Nullable private final PsiCallExpression myCall;
-  @Nullable private PsiType myType;
-  @NotNull private final PsiExpression[] myArgs;
-  private boolean myShouldFlushFields;
-  @NotNull private final PsiExpression myContext;
-  private final MethodType myMethodType;
-  @Nullable private DfaValue myPrecalculatedReturnValue;
-  public enum MethodType {
-    BOXING, UNBOXING, REGULAR_METHOD_CALL, CAST
-  }
-
-  public MethodCallInstruction(@NotNull PsiCallExpression callExpression, @Nullable DfaValue precalculatedReturnValue) {
-    this(callExpression, MethodType.REGULAR_METHOD_CALL);
-    myPrecalculatedReturnValue = precalculatedReturnValue;
-  }
-
-  public MethodCallInstruction(@NotNull PsiExpression context, MethodType methodType, @Nullable PsiType resultType) {
-    this(context, methodType);
-    myType = resultType;
-    myShouldFlushFields = false;
-  }
-
-  public MethodCallInstruction(@NotNull PsiExpression context, MethodType methodType) {
-    myContext = context;
-    myMethodType = methodType;
-    myCall = methodType == MethodType.REGULAR_METHOD_CALL && context instanceof PsiCallExpression ? (PsiCallExpression)context : null;
-    final PsiExpressionList argList = myCall == null ? null : myCall.getArgumentList();
-    myArgs = argList != null ? argList.getExpressions() : PsiExpression.EMPTY_ARRAY;
-
-    myType = myCall == null ? null : myCall.getType();
-
-    myShouldFlushFields = true;
-    if (myCall instanceof PsiNewExpression && myType != null && myType.getArrayDimensions() > 0) {
-      myShouldFlushFields = false;
-    }
-  }
-
-  public void setShouldFlushFields(boolean shouldFlushFields) {
-    myShouldFlushFields = shouldFlushFields;
-  }
-
-  @Nullable
-  public PsiType getResultType() {
-    return myType;
-  }
-
-  @NotNull
-  public PsiExpression[] getArgs() {
-    return myArgs;
-  }
-
-  public MethodType getMethodType() {
-    return myMethodType;
-  }
-
-  public boolean shouldFlushFields() {
-    return myShouldFlushFields;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitMethodCall(this, runner, stateBefore);
-  }
-
-  @Nullable
-  public PsiCallExpression getCallExpression() {
-    return myCall;
-  }
-
-  @NotNull
-  public PsiExpression getContext() {
-    return myContext;
-  }
-
-  @Nullable
-  public DfaValue getPrecalculatedReturnValue() {
-    return myPrecalculatedReturnValue;
-  }
-
-  public String toString() {
-    return myMethodType == MethodType.UNBOXING
-           ? "UNBOX"
-           : myMethodType == MethodType.BOXING
-             ? "BOX" :
-             "CALL_METHOD: " + (myCall == null ? "null" : myCall.getText());
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/NotInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/NotInstruction.java
deleted file mode 100644
index 846078e..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/NotInstruction.java
+++ /dev/null
@@ -1,40 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Feb 7, 2002
- * Time: 2:32:58 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.*;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-
-public class NotInstruction extends Instruction {
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitNot(this, runner, stateBefore);
-  }
-
-  public String toString() {
-    return "NOT";
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/PopInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/PopInstruction.java
deleted file mode 100644
index e8c3b94..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/PopInstruction.java
+++ /dev/null
@@ -1,40 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Feb 7, 2002
- * Time: 2:32:35 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.*;
-
-public class PopInstruction extends Instruction {
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    stateBefore.pop();
-    return nextInstruction(runner, stateBefore);
-  }
-
-  public String toString() {
-    return "POP";
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/PushInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/PushInstruction.java
deleted file mode 100644
index 6915f67..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/PushInstruction.java
+++ /dev/null
@@ -1,65 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Feb 7, 2002
- * Time: 1:25:41 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.codeInspection.dataFlow.value.DfaUnknownValue;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-import com.intellij.psi.PsiExpression;
-import com.intellij.psi.PsiField;
-import com.intellij.psi.PsiReferenceExpression;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class PushInstruction extends Instruction {
-  private final DfaValue myValue;
-  private final PsiExpression myPlace;
-
-  public PushInstruction(@Nullable DfaValue value, PsiExpression place) {
-    myValue = value != null ? value : DfaUnknownValue.getInstance();
-    myPlace = place;
-  }
-
-  @NotNull
-  public DfaValue getValue() {
-    return myValue;
-  }
-
-  public PsiExpression getPlace() {
-    return myPlace;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitPush(this, runner, stateBefore);
-  }
-
-  public String toString() {
-    return "PUSH " + myValue;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/ReturnFromSubInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/ReturnFromSubInstruction.java
deleted file mode 100644
index 334573c..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/ReturnFromSubInstruction.java
+++ /dev/null
@@ -1,37 +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.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-
-/**
- * @author max
- */
-public class ReturnFromSubInstruction extends Instruction{
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState memState, InstructionVisitor visitor) {
-    int offset = memState.popOffset();
-    return new DfaInstructionState[] {new DfaInstructionState(runner.getInstruction(offset), memState)};
-  }
-
-  public String toString() {
-    return "RETURN_FROM_SUB";
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/ReturnInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/ReturnInstruction.java
deleted file mode 100644
index d3c1d87..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/ReturnInstruction.java
+++ /dev/null
@@ -1,39 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 28, 2002
- * Time: 10:05:49 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.*;
-
-public class ReturnInstruction extends Instruction {
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return DfaInstructionState.EMPTY_ARRAY;
-  }
-
-  public String toString() {
-    return "RETURN";
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/SwapInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/SwapInstruction.java
deleted file mode 100644
index 791d311..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/SwapInstruction.java
+++ /dev/null
@@ -1,42 +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.dataFlow.instructions;
-
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-import com.intellij.codeInspection.dataFlow.value.DfaValue;
-
-/**
- * @author max
- */
-public class SwapInstruction extends Instruction {
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    final DfaValue a = stateBefore.pop();
-    final DfaValue b = stateBefore.pop();
-    stateBefore.push(a);
-    stateBefore.push(b);
-    Instruction nextInstruction = runner.getInstruction(getIndex() + 1);
-    return new DfaInstructionState[]{new DfaInstructionState(nextInstruction, stateBefore)};
-  }
-
-  public String toString() {
-    return "SWAP";
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/TypeCastInstruction.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/TypeCastInstruction.java
deleted file mode 100644
index 0e3a021..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/instructions/TypeCastInstruction.java
+++ /dev/null
@@ -1,62 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Apr 9, 2002
- * Time: 10:27:17 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.instructions;
-
-import com.intellij.psi.PsiExpression;
-import com.intellij.psi.PsiType;
-import com.intellij.psi.PsiTypeCastExpression;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
-
-public class TypeCastInstruction extends Instruction {
-  private final PsiTypeCastExpression myCastExpression;
-  private final PsiExpression myCasted;
-  private final PsiType myCastTo;
-
-  public TypeCastInstruction(PsiTypeCastExpression castExpression, PsiExpression casted, PsiType castTo) {
-    myCastExpression = castExpression;
-    myCasted = casted;
-    myCastTo = castTo;
-  }
-
-  public PsiTypeCastExpression getCastExpression() {
-    return myCastExpression;
-  }
-
-  public PsiExpression getCasted() {
-    return myCasted;
-  }
-
-  public PsiType getCastTo() {
-    return myCastTo;
-  }
-
-  @Override
-  public DfaInstructionState[] accept(DataFlowRunner runner, DfaMemoryState stateBefore, InstructionVisitor visitor) {
-    return visitor.visitTypeCast(this, runner, stateBefore);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaBoxedValue.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaBoxedValue.java
deleted file mode 100644
index c401bf2..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaBoxedValue.java
+++ /dev/null
@@ -1,88 +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.dataFlow.value;
-
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.HashMap;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Map;
-
-public class DfaBoxedValue extends DfaValue {
-  private final DfaValue myWrappedValue;
-
-  private DfaBoxedValue(DfaValue valueToWrap, DfaValueFactory factory) {
-    super(factory);
-    myWrappedValue = valueToWrap;
-  }
-
-  @NonNls
-  public String toString() {
-    return "Boxed "+myWrappedValue.toString();
-  }
-
-  public DfaValue getWrappedValue() {
-    return myWrappedValue;
-  }
-
-  public static class Factory {
-    private final Map<Object, DfaBoxedValue> cachedValues = new HashMap<Object, DfaBoxedValue>();
-    private final DfaValueFactory myFactory;
-
-    public Factory(DfaValueFactory factory) {
-      myFactory = factory;
-    }
-
-    @Nullable
-    public DfaValue createBoxed(DfaValue valueToWrap) {
-      if (valueToWrap instanceof DfaUnboxedValue) return ((DfaUnboxedValue)valueToWrap).getVariable();
-      Object o = valueToWrap instanceof DfaConstValue
-                 ? ((DfaConstValue)valueToWrap).getValue()
-                 : valueToWrap instanceof DfaVariableValue ? valueToWrap : null;
-      if (o == null) return null;
-      DfaBoxedValue boxedValue = cachedValues.get(o);
-      if (boxedValue == null) {
-        cachedValues.put(o, boxedValue = new DfaBoxedValue(valueToWrap, myFactory));
-      }
-      return boxedValue;
-    }
-
-    private final Map<DfaVariableValue, DfaUnboxedValue> cachedUnboxedValues = ContainerUtil.newTroveMap();
-
-    @NotNull
-    public DfaValue createUnboxed(DfaValue value) {
-      if (value instanceof DfaBoxedValue) {
-        return ((DfaBoxedValue)value).getWrappedValue();
-      }
-      if (value instanceof DfaConstValue) {
-        if (value == value.myFactory.getConstFactory().getNull()) return DfaUnknownValue.getInstance();
-        return value;
-      }
-      if (value instanceof DfaVariableValue) {
-        DfaVariableValue var = (DfaVariableValue)value;
-        DfaUnboxedValue result = cachedUnboxedValues.get(var);
-        if (result == null) {
-          cachedUnboxedValues.put(var, result = new DfaUnboxedValue(var, myFactory));
-        }
-        return result;
-      }
-      return DfaUnknownValue.getInstance();
-    }
-
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaConstValue.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaConstValue.java
deleted file mode 100644
index 5614751..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaConstValue.java
+++ /dev/null
@@ -1,138 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 28, 2002
- * Time: 6:31:23 PM
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.value;
-
-import com.intellij.psi.*;
-import com.intellij.psi.util.TypeConversionUtil;
-import com.intellij.util.containers.HashMap;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Map;
-
-public class DfaConstValue extends DfaValue {
-  public static class Factory {
-    private final DfaConstValue dfaNull;
-    private final DfaConstValue dfaFalse;
-    private final DfaConstValue dfaTrue;
-    private final DfaValueFactory myFactory;
-    private final Map<Object, DfaConstValue> myValues;
-
-    Factory(DfaValueFactory factory) {
-      myFactory = factory;
-      myValues = new HashMap<Object, DfaConstValue>();
-      dfaNull = new DfaConstValue(null, factory);
-      dfaFalse = new DfaConstValue(Boolean.FALSE, factory);
-      dfaTrue = new DfaConstValue(Boolean.TRUE, factory);
-    }
-
-    @Nullable
-    public DfaValue create(PsiLiteralExpression expr) {
-      PsiType type = expr.getType();
-      if (PsiType.NULL.equals(type)) return dfaNull;
-      Object value = expr.getValue();
-      if (value == null) return null;
-      return createFromValue(value, type);
-    }
-
-    @Nullable
-    public DfaValue create(PsiVariable variable) {
-      Object value = variable.computeConstantValue();
-      PsiType type = variable.getType();
-      if (value == null) {
-        Boolean boo = computeJavaLangBooleanFieldReference(variable);
-        if (boo != null) {
-          DfaConstValue unboxed = createFromValue(boo, PsiType.BOOLEAN);
-          return myFactory.getBoxedFactory().createBoxed(unboxed);
-        }
-        return null;
-      }
-      return createFromValue(value, type);
-    }
-
-    @Nullable
-    private static Boolean computeJavaLangBooleanFieldReference(final PsiVariable variable) {
-      if (!(variable instanceof PsiField)) return null;
-      PsiClass psiClass = ((PsiField)variable).getContainingClass();
-      if (psiClass == null || !CommonClassNames.JAVA_LANG_BOOLEAN.equals(psiClass.getQualifiedName())) return null;
-      @NonNls String name = variable.getName();
-      return "TRUE".equals(name) ? Boolean.TRUE : "FALSE".equals(name) ? Boolean.FALSE : null;
-    }
-
-    @NotNull
-    public DfaConstValue createFromValue(Object value, final PsiType type) {
-      if (value == Boolean.TRUE) return dfaTrue;
-      if (value == Boolean.FALSE) return dfaFalse;
-
-      if (TypeConversionUtil.isNumericType(type) && !TypeConversionUtil.isFloatOrDoubleType(type)) {
-        value = TypeConversionUtil.computeCastTo(value, PsiType.LONG);
-      }
-      DfaConstValue instance = myValues.get(value);
-      if (instance == null) {
-        instance = new DfaConstValue(value, myFactory);
-        myValues.put(value, instance);
-      }
-
-      return instance;
-    }
-
-    public DfaConstValue getFalse() {
-      return dfaFalse;
-    }
-
-    public DfaConstValue getTrue() {
-      return dfaTrue;
-    }
-
-    public DfaConstValue getNull() {
-      return dfaNull;
-    }
-  }
-
-  private final Object myValue;
-
-  DfaConstValue(Object value, DfaValueFactory factory) {
-    super(factory);
-    myValue = value;
-  }
-
-  @SuppressWarnings({"HardCodedStringLiteral"})
-  public String toString() {
-    if (myValue == null) return "null";
-    return myValue.toString();
-  }
-
-  public Object getValue() {
-    return myValue;
-  }
-
-  @Override
-  public DfaValue createNegated() {
-    if (this == myFactory.getConstFactory().getTrue()) return myFactory.getConstFactory().getFalse();
-    if (this == myFactory.getConstFactory().getFalse()) return myFactory.getConstFactory() .getTrue();
-    return DfaUnknownValue.getInstance();
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaNotNullValue.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaNotNullValue.java
deleted file mode 100644
index ff2c69f..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaNotNullValue.java
+++ /dev/null
@@ -1,92 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 28, 2002
- * Time: 6:45:14 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.value;
-
-import com.intellij.psi.PsiType;
-import com.intellij.util.containers.HashMap;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-
-public class DfaNotNullValue extends DfaValue {
-  public static class Factory {
-    private final DfaNotNullValue mySharedInstance;
-    private final HashMap<String,ArrayList<DfaNotNullValue>> myStringToObject;
-    private final DfaValueFactory myFactory;
-
-    Factory(DfaValueFactory factory) {
-      myFactory = factory;
-      mySharedInstance = new DfaNotNullValue(factory);
-      myStringToObject = new HashMap<String, ArrayList<DfaNotNullValue>>();
-    }
-
-    @NotNull
-    public DfaValue create(@Nullable PsiType type) {
-      if (type == null) return DfaUnknownValue.getInstance();
-      mySharedInstance.myType = type;
-
-      String id = mySharedInstance.toString();
-      ArrayList<DfaNotNullValue> conditions = myStringToObject.get(id);
-      if (conditions == null) {
-        conditions = new ArrayList<DfaNotNullValue>();
-        myStringToObject.put(id, conditions);
-      }
-      else {
-        for (DfaNotNullValue value : conditions) {
-          if (value.hardEquals(mySharedInstance)) return value;
-        }
-      }
-
-      DfaNotNullValue result = new DfaNotNullValue(type, myFactory);
-      conditions.add(result);
-      return result;
-    }
-  }
-
-  private PsiType myType;
-
-  private DfaNotNullValue(PsiType myType, DfaValueFactory factory) {
-    super(factory);
-    this.myType = myType;
-  }
-
-  private DfaNotNullValue(DfaValueFactory factory) {
-    super(factory);
-  }
-
-  @SuppressWarnings({"HardCodedStringLiteral"})
-  public String toString() {
-    return "@notnull " + myType.getCanonicalText();
-  }
-
-  public PsiType getType() {
-    return myType;
-  }
-
-  private boolean hardEquals(DfaNotNullValue aNotNull) {
-    return aNotNull.myType == myType;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaRelationValue.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaRelationValue.java
deleted file mode 100644
index ad375d7..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaRelationValue.java
+++ /dev/null
@@ -1,174 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Feb 6, 2002
- * Time: 10:01:02 PM
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.value;
-
-import com.intellij.openapi.util.Comparing;
-import com.intellij.psi.tree.IElementType;
-import com.intellij.util.containers.HashMap;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-
-import static com.intellij.psi.JavaTokenType.*;
-
-public class DfaRelationValue extends DfaValue {
-  private DfaValue myLeftOperand;
-  private DfaValue myRightOperand;
-  private IElementType myRelation;
-  private boolean myIsNegated;
-
-  public static class Factory {
-    private final DfaRelationValue mySharedInstance;
-    private final HashMap<String,ArrayList<DfaRelationValue>> myStringToObject;
-    private final DfaValueFactory myFactory;
-
-    Factory(DfaValueFactory factory) {
-      myFactory = factory;
-      mySharedInstance = new DfaRelationValue(factory);
-      myStringToObject = new HashMap<String, ArrayList<DfaRelationValue>>();
-    }
-
-    public DfaRelationValue createRelation(DfaValue dfaLeft, DfaValue dfaRight, IElementType relation, boolean negated) {
-      if (dfaRight instanceof DfaTypeValue && INSTANCEOF_KEYWORD != relation) return null;
-      if (PLUS == relation) return null;
-
-      if (dfaLeft instanceof DfaVariableValue || dfaLeft instanceof DfaBoxedValue || dfaLeft instanceof DfaUnboxedValue
-          || dfaRight instanceof DfaVariableValue || dfaRight instanceof DfaBoxedValue || dfaRight instanceof DfaUnboxedValue) {
-        if (!(dfaLeft instanceof DfaVariableValue || dfaLeft instanceof DfaBoxedValue || dfaLeft instanceof DfaUnboxedValue)) {
-          return createRelation(dfaRight, dfaLeft, getSymmetricOperation(relation), negated);
-        }
-
-        return createCanonicalRelation(relation, negated, dfaLeft, dfaRight);
-      }
-      if (dfaLeft instanceof DfaNotNullValue && dfaRight instanceof DfaConstValue) {
-        return createCanonicalRelation(relation, negated, dfaLeft, dfaRight);
-      }
-      else if (dfaRight instanceof DfaNotNullValue && dfaLeft instanceof DfaConstValue) {
-        return createCanonicalRelation(relation, negated, dfaRight, dfaLeft);
-      }
-      else {
-        return null;
-      }
-    }
-
-    private DfaRelationValue createCanonicalRelation(IElementType relation,
-                                                     boolean negated,
-                                                     final DfaValue dfaLeft,
-                                                     final DfaValue dfaRight) {
-      // To canonical form.
-      if (NE == relation) {
-        relation = EQEQ;
-        negated = !negated;
-      }
-      else if (LT == relation) {
-        relation = GE;
-        negated = !negated;
-      }
-      else if (LE == relation) {
-        relation = GT;
-        negated = !negated;
-      }
-
-      mySharedInstance.myLeftOperand = dfaLeft;
-      mySharedInstance.myRightOperand = dfaRight;
-      mySharedInstance.myRelation = relation;
-      mySharedInstance.myIsNegated = negated;
-
-      String id = mySharedInstance.toString();
-      ArrayList<DfaRelationValue> conditions = myStringToObject.get(id);
-      if (conditions == null) {
-        conditions = new ArrayList<DfaRelationValue>();
-        myStringToObject.put(id, conditions);
-      }
-      else {
-        for (DfaRelationValue rel : conditions) {
-          if (rel.hardEquals(mySharedInstance)) return rel;
-        }
-      }
-
-      DfaRelationValue result = new DfaRelationValue(dfaLeft, dfaRight, relation, negated, myFactory);
-      conditions.add(result);
-      return result;
-    }
-
-    private static IElementType getSymmetricOperation(IElementType sign) {
-      if (LT == sign) return GT;
-      if (GE == sign) return LE;
-      if (GT == sign) return LT;
-      if (LE == sign) return GE;
-      return sign;
-    }
-  }
-
-  private DfaRelationValue(DfaValueFactory factory) {
-    super(factory);
-  }
-
-  private DfaRelationValue(DfaValue myLeftOperand, DfaValue myRightOperand, IElementType myRelation, boolean myIsNegated,
-                           DfaValueFactory factory) {
-    super(factory);
-    this.myLeftOperand = myLeftOperand;
-    this.myRightOperand = myRightOperand;
-    this.myRelation = myRelation;
-    this.myIsNegated = myIsNegated;
-  }
-
-  public DfaValue getLeftOperand() {
-    return myLeftOperand;
-  }
-
-  public DfaValue getRightOperand() {
-    return myRightOperand;
-  }
-
-  public boolean isNegated() {
-    return myIsNegated;
-  }
-
-  @Override
-  public DfaValue createNegated() {
-    return myFactory.getRelationFactory().createRelation(myLeftOperand, myRightOperand, myRelation, !myIsNegated);
-  }
-
-  private boolean hardEquals(DfaRelationValue rel) {
-    return Comparing.equal(rel.myLeftOperand,myLeftOperand)
-      && Comparing.equal(rel.myRightOperand,myRightOperand) &&
-      rel.myRelation == myRelation &&
-      rel.myIsNegated == myIsNegated;
-  }
-
-  public boolean isEquality() {
-    return myRelation == EQEQ && !myIsNegated;
-  }
-
-  public boolean isNonEquality() {
-    return myRelation == EQEQ && myIsNegated || myRelation == GT && !myIsNegated || myRelation == GE && myIsNegated;
-  }
-
-  @NonNls public String toString() {
-    return (isNegated() ? "not " : "") + myLeftOperand + " " + myRelation + " " + myRightOperand;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaTypeValue.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaTypeValue.java
deleted file mode 100644
index 9d954b5..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaTypeValue.java
+++ /dev/null
@@ -1,123 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 28, 2002
- * Time: 6:32:01 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.value;
-
-import com.intellij.openapi.util.Comparing;
-import com.intellij.psi.PsiKeyword;
-import com.intellij.psi.PsiType;
-import com.intellij.util.containers.HashMap;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.ArrayList;
-
-public class DfaTypeValue extends DfaValue {
-  public static class Factory {
-    private final DfaTypeValue mySharedInstance;
-    private final HashMap<String,ArrayList<DfaTypeValue>> myStringToObject;
-    private final DfaValueFactory myFactory;
-
-    Factory(DfaValueFactory factory) {
-      myFactory = factory;
-      mySharedInstance = new DfaTypeValue(factory);
-      myStringToObject = new HashMap<String, ArrayList<DfaTypeValue>>();
-    }
-
-    @NotNull
-    public DfaTypeValue create(@NotNull PsiType type, boolean nullable) {
-      mySharedInstance.myType = type;
-      mySharedInstance.myCanonicalText = type.getCanonicalText();
-      mySharedInstance.myIsNullable = nullable;
-      if (mySharedInstance.myCanonicalText == null) {
-        mySharedInstance.myCanonicalText = PsiKeyword.NULL;
-      }
-
-      String id = mySharedInstance.toString();
-      ArrayList<DfaTypeValue> conditions = myStringToObject.get(id);
-      if (conditions == null) {
-        conditions = new ArrayList<DfaTypeValue>();
-        myStringToObject.put(id, conditions);
-      } else {
-        for (DfaTypeValue aType : conditions) {
-          if (aType.hardEquals(mySharedInstance)) return aType;
-        }
-      }
-
-      DfaTypeValue result = new DfaTypeValue(type, nullable, myFactory);
-      conditions.add(result);
-      return result;
-    }
-
-    public DfaTypeValue create(@NotNull PsiType type) {
-      return create(type, false);
-    }
-  }
-
-  private PsiType myType;
-  private String myCanonicalText;
-  private boolean myIsNullable;
-
-  private DfaTypeValue(DfaValueFactory factory) {
-    super(factory);
-  }
-
-  private DfaTypeValue(PsiType type, boolean isNullable, DfaValueFactory factory) {
-    super(factory);
-    myType = type;
-    myIsNullable = isNullable;
-    myCanonicalText = type.getCanonicalText();
-    if (myCanonicalText == null) {
-      myCanonicalText = PsiKeyword.NULL;
-    }
-  }
-
-  public PsiType getType() {
-    return myType;
-  }
-
-  public boolean isNullable() {
-    return myIsNullable;
-  }
-
-  @NonNls
-  public String toString() {
-    return myCanonicalText + ", nullable=" + myIsNullable;
-  }
-
-  private boolean hardEquals(DfaTypeValue aType) {
-    return Comparing.equal(myCanonicalText, aType.myCanonicalText) && myIsNullable == aType.myIsNullable;
-  }
-
-  public boolean isAssignableFrom(DfaTypeValue dfaType) {
-    return dfaType != null && myType.isAssignableFrom(dfaType.myType);
-  }
-
-  public boolean isConvertibleFrom(DfaTypeValue dfaType) {
-    if (dfaType == null) return false;
-    assert myType.isValid() : "my type invalid";
-    assert dfaType.myType.isValid() : " their type invalid";
-    return myType.isConvertibleFrom(dfaType.myType);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaUnboxedValue.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaUnboxedValue.java
deleted file mode 100644
index 032272a..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaUnboxedValue.java
+++ /dev/null
@@ -1,46 +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.dataFlow.value;
-
-import org.jetbrains.annotations.NonNls;
-
-public class DfaUnboxedValue extends DfaValue {
-  private final DfaVariableValue myVariable;
-
-  DfaUnboxedValue(DfaVariableValue valueToWrap, DfaValueFactory factory) {
-    super(factory);
-    myVariable = valueToWrap;
-  }
-
-  @NonNls
-  public String toString() {
-    return "Unboxed "+myVariable.toString();
-  }
-
-  public DfaVariableValue getVariable() {
-    return myVariable;
-  }
-
-
-  public boolean isNegated() {
-    return myVariable.isNegated();
-  }
-
-  @Override
-  public DfaValue createNegated() {
-    return myFactory.getBoxedFactory().createUnboxed(myVariable.createNegated());
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaUnknownValue.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaUnknownValue.java
deleted file mode 100644
index b5ab771..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaUnknownValue.java
+++ /dev/null
@@ -1,62 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Feb 7, 2002
- * Time: 11:23:22 AM
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.value;
-
-public class DfaUnknownValue extends DfaValue {
-  private static class DfaUnknownValueHolder {
-    private static final DfaUnknownValue myInstance = new DfaUnknownValue();
-  }
-  public static DfaUnknownValue getInstance() {
-    return DfaUnknownValueHolder.myInstance;
-  }
-
-  private DfaUnknownValue() {
-    super(null);
-  }
-
-  @Override
-  public DfaValue createNegated() {
-    return this;
-  }
-
-  @SuppressWarnings({"HardCodedStringLiteral"})
-  public String toString() {
-    return "<unknown>";
-  }
-
-  public boolean equals(Object obj) {
-    return obj == this;
-  }
-
-  public int hashCode() {
-    return 0;
-  }
-
-  @Override
-  public int getID() {
-    return 0;
-  }
-
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaValue.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaValue.java
deleted file mode 100644
index e19b3ce..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaValue.java
+++ /dev/null
@@ -1,48 +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.dataFlow.value;
-
-public class DfaValue {
-  private final int myID;
-  protected final DfaValueFactory myFactory;
-
-  protected DfaValue(final DfaValueFactory factory) {
-    myFactory = factory;
-    if (factory == null) {
-      myID = 0;
-    }
-    else {
-      myID = factory.createID();
-      factory.registerValue(this);
-    }
-  }
-
-  public int getID() {
-    return myID;
-  }
-
-  public DfaValue createNegated() {
-    return DfaUnknownValue.getInstance();
-  }
-
-  public boolean equals(Object obj) {
-    return obj instanceof DfaValue && getID() == ((DfaValue)obj).getID();
-  }
-
-  public int hashCode() {
-    return getID();
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaValueFactory.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaValueFactory.java
deleted file mode 100644
index dcc4a3f..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaValueFactory.java
+++ /dev/null
@@ -1,208 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Feb 7, 2002
- * Time: 2:33:28 PM
- * To change template for new class use 
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.value;
-
-import com.intellij.codeInspection.dataFlow.Nullness;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.JavaConstantExpressionEvaluator;
-import com.intellij.psi.util.PsiTreeUtil;
-import gnu.trove.TIntObjectHashMap;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class DfaValueFactory {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.value.DfaValueFactory");
-
-  private int myLastID;
-  private final TIntObjectHashMap<DfaValue> myValues;
-
-  public DfaValueFactory() {
-    myValues = new TIntObjectHashMap<DfaValue>();
-    myLastID = 0;
-
-    myVarFactory = new DfaVariableValue.Factory(this);
-    myConstFactory = new DfaConstValue.Factory(this);
-    myBoxedFactory = new DfaBoxedValue.Factory(this);
-    myNotNullFactory = new DfaNotNullValue.Factory(this);
-    myTypeFactory = new DfaTypeValue.Factory(this);
-    myRelationFactory = new DfaRelationValue.Factory(this);
-  }
-
-  public DfaValue createTypeValueWithNullability(@Nullable PsiType type, Nullness nullability) {
-    return nullability == Nullness.NOT_NULL ? getNotNullFactory().create(type) : getTypeFactory().create(type, nullability == Nullness.NULLABLE);
-  }
-
-   int createID() {
-    myLastID++;
-    LOG.assertTrue(myLastID >= 0, "Overflow");
-    return myLastID;
-  }
-
-  void registerValue(DfaValue value) {
-    myValues.put(value.getID(), value);
-  }
-
-  public DfaValue getValue(int id) {
-    return myValues.get(id);
-  }
-
-  @Nullable
-  public DfaValue createValue(PsiExpression psiExpression) {
-    if (psiExpression instanceof PsiReferenceExpression) {
-      return createReferenceValue((PsiReferenceExpression)psiExpression);
-    }
-
-    if (psiExpression instanceof PsiLiteralExpression) {
-      return createLiteralValue((PsiLiteralExpression)psiExpression);
-    }
-
-    if (psiExpression instanceof PsiNewExpression) {
-      return getNotNullFactory().create(psiExpression.getType());
-    }
-
-    final Object value = JavaConstantExpressionEvaluator.computeConstantExpression(psiExpression, false);
-    PsiType type = psiExpression.getType();
-    if (value != null && type != null) {
-      if (value instanceof String) {
-        return getNotNullFactory().create(type); // Non-null string literal.
-      }
-      return getConstFactory().createFromValue(value, type);
-    }
-
-    return null;
-  }
-
-  @Nullable
-  public DfaValue createLiteralValue(PsiLiteralExpression literal) {
-    if (literal.getValue() instanceof String) {
-      return getNotNullFactory().create(literal.getType()); // Non-null string literal.
-    }
-    return getConstFactory().create(literal);
-  }
-
-  private static boolean isNotNullExpression(PsiExpression initializer, PsiType type) {
-    if (initializer instanceof PsiNewExpression) {
-      return true;
-    }
-    if (initializer instanceof PsiPolyadicExpression) {
-      if (type != null && type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
-        return true;
-      }
-    }
-
-    return false;
-  }
-
-  @Nullable
-  public DfaValue createReferenceValue(PsiReferenceExpression referenceExpression) {
-    PsiElement psiSource = referenceExpression.resolve();
-    if (!(psiSource instanceof PsiVariable)) {
-      return null;
-    }
-
-    final PsiVariable variable = (PsiVariable)psiSource;
-    if (variable.hasModifierProperty(PsiModifier.FINAL) && !variable.hasModifierProperty(PsiModifier.TRANSIENT)) {
-      DfaValue constValue = getConstFactory().create(variable);
-      if (constValue != null) return constValue;
-
-      PsiExpression initializer = variable.getInitializer();
-      PsiType type = initializer == null ? null : initializer.getType();
-      if (initializer != null && type != null && isNotNullExpression(initializer, type)) {
-        return getNotNullFactory().create(type);
-      }
-    }
-
-    if (!variable.hasModifierProperty(PsiModifier.VOLATILE) && isEffectivelyUnqualified(referenceExpression)) {
-      return getVarFactory().createVariableValue(variable, referenceExpression.getType(), false, null, false);
-    }
-
-    return null;
-  }
-
-  @Nullable
-  public static PsiVariable resolveUnqualifiedVariable(PsiReferenceExpression refExpression) {
-    if (isEffectivelyUnqualified(refExpression)) {
-      PsiElement resolved = refExpression.resolve();
-      if (resolved instanceof PsiVariable) {
-        return (PsiVariable)resolved;
-      }
-    }
-
-    return null;
-  }
-
-  public static boolean isEffectivelyUnqualified(PsiReferenceExpression refExpression) {
-    PsiExpression qualifier = refExpression.getQualifierExpression();
-    if (qualifier == null) {
-      return true;
-    }
-    if (qualifier instanceof PsiThisExpression || qualifier instanceof PsiSuperExpression) {
-      final PsiJavaCodeReferenceElement thisQualifier = ((PsiQualifiedExpression)qualifier).getQualifier();
-      if (thisQualifier == null) return true;
-      final PsiClass innerMostClass = PsiTreeUtil.getParentOfType(refExpression, PsiClass.class);
-      if (innerMostClass == thisQualifier.resolve()) {
-        return true;
-      }
-    }
-    return false;
-  }
-
-  private final DfaVariableValue.Factory myVarFactory;
-  private final DfaConstValue.Factory myConstFactory;
-  private final DfaBoxedValue.Factory myBoxedFactory;
-  private final DfaNotNullValue.Factory myNotNullFactory;
-  private final DfaTypeValue.Factory myTypeFactory;
-  private final DfaRelationValue.Factory myRelationFactory;
-
-  @NotNull
-  public DfaVariableValue.Factory getVarFactory() {
-    return myVarFactory;
-  }
-
-  @NotNull
-  public DfaConstValue.Factory getConstFactory() {
-    return myConstFactory;
-  }
-  @NotNull
-  public DfaBoxedValue.Factory getBoxedFactory() {
-    return myBoxedFactory;
-  }
-
-  @NotNull
-  public DfaNotNullValue.Factory getNotNullFactory() {
-    return myNotNullFactory;
-  }
-
-  @NotNull
-  public DfaTypeValue.Factory getTypeFactory() {
-    return myTypeFactory;
-  }
-
-  @NotNull
-  public DfaRelationValue.Factory getRelationFactory() {
-    return myRelationFactory;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java
deleted file mode 100644
index 758059b..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java
+++ /dev/null
@@ -1,177 +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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: Jan 28, 2002
- * Time: 6:31:08 PM
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.dataFlow.value;
-
-import com.intellij.codeInspection.dataFlow.DfaUtil;
-import com.intellij.codeInspection.dataFlow.Nullness;
-import com.intellij.psi.PsiType;
-import com.intellij.psi.PsiVariable;
-import com.intellij.util.containers.HashMap;
-import com.intellij.util.containers.MultiMap;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class DfaVariableValue extends DfaValue {
-
-  public static class Factory {
-    private final DfaVariableValue mySharedInstance;
-    private final HashMap<String,ArrayList<DfaVariableValue>> myStringToObject = new HashMap<String, ArrayList<DfaVariableValue>>();
-    private final DfaValueFactory myFactory;
-    private final MultiMap<DfaVariableValue, DfaVariableValue> myQualifiersToChainedVariables = new MultiMap<DfaVariableValue, DfaVariableValue>();
-
-    Factory(DfaValueFactory factory) {
-      myFactory = factory;
-      mySharedInstance = new DfaVariableValue(factory);
-    }
-
-    public DfaVariableValue createVariableValue(PsiVariable myVariable, boolean isNegated) {
-      return createVariableValue(myVariable, myVariable.getType(), isNegated, null, false);
-    }
-    @NotNull
-    public DfaVariableValue createVariableValue(PsiVariable myVariable,
-                                                @Nullable PsiType varType, boolean isNegated, @Nullable DfaVariableValue qualifier, boolean viaMethods) {
-      mySharedInstance.myVariable = myVariable;
-      mySharedInstance.myIsNegated = isNegated;
-      mySharedInstance.myQualifier = qualifier;
-      mySharedInstance.myViaMethods = viaMethods;
-
-      String id = mySharedInstance.toString();
-      ArrayList<DfaVariableValue> conditions = myStringToObject.get(id);
-      if (conditions == null) {
-        conditions = new ArrayList<DfaVariableValue>();
-        myStringToObject.put(id, conditions);
-      }
-      else {
-        for (DfaVariableValue aVar : conditions) {
-          if (aVar.hardEquals(mySharedInstance)) return aVar;
-        }
-      }
-
-      DfaVariableValue result = new DfaVariableValue(myVariable, varType, isNegated, myFactory, qualifier, viaMethods);
-      if (qualifier != null) {
-        myQualifiersToChainedVariables.putValue(qualifier, result);
-      }
-      conditions.add(result);
-      return result;
-    }
-
-    public List<DfaVariableValue> getAllQualifiedBy(DfaVariableValue value) {
-      ArrayList<DfaVariableValue> result = new ArrayList<DfaVariableValue>();
-      for (DfaVariableValue directQualified : myQualifiersToChainedVariables.get(value)) {
-        result.add(directQualified);
-        result.addAll(getAllQualifiedBy(directQualified));
-      }
-      return result;
-    }
-
-  }
-
-  private PsiVariable myVariable;
-  private PsiType myVarType;
-  @Nullable private DfaVariableValue myQualifier;
-  private boolean myIsNegated;
-  private boolean myViaMethods;
-  private Nullness myInherentNullability;
-
-  private DfaVariableValue(PsiVariable variable, PsiType varType, boolean isNegated, DfaValueFactory factory, @Nullable DfaVariableValue qualifier, boolean viaMethods) {
-    super(factory);
-    myVariable = variable;
-    myIsNegated = isNegated;
-    myQualifier = qualifier;
-    myViaMethods = viaMethods;
-    myVarType = varType;
-  }
-
-  private DfaVariableValue(DfaValueFactory factory) {
-    super(factory);
-    myVariable = null;
-    myIsNegated = false;
-  }
-
-  @Nullable
-  public PsiVariable getPsiVariable() {
-    return myVariable;
-  }
-
-  @Nullable
-  public PsiType getVariableType() {
-    return myVarType;
-  }
-
-  public boolean isNegated() {
-    return myIsNegated;
-  }
-
-  @Override
-  public DfaVariableValue createNegated() {
-    return myFactory.getVarFactory().createVariableValue(myVariable, myVarType, !myIsNegated, myQualifier, myViaMethods);
-  }
-
-  @SuppressWarnings({"HardCodedStringLiteral"})
-  public String toString() {
-    if (myVariable == null) return "$currentException";
-    return (myIsNegated ? "!" : "") + myVariable.getName() + (myQualifier == null ? "" : "|" + myQualifier.toString());
-  }
-
-  private boolean hardEquals(DfaVariableValue aVar) {
-    return aVar.myVariable == myVariable &&
-           aVar.myIsNegated == myIsNegated &&
-           aVar.myViaMethods == myViaMethods &&
-           (myQualifier == null ? aVar.myQualifier == null : myQualifier.hardEquals(aVar.myQualifier));
-  }
-
-  @Nullable
-  public DfaVariableValue getQualifier() {
-    return myQualifier;
-  }
-
-  public boolean isViaMethods() {
-    return myViaMethods;
-  }
-
-  public Nullness getInherentNullability() {
-    if (myInherentNullability != null) {
-      return myInherentNullability;
-    }
-
-    PsiVariable var = getPsiVariable();
-    Nullness nullability = DfaUtil.getElementNullability(getVariableType(), var);
-    if (nullability == Nullness.UNKNOWN && var != null) {
-      if (DfaUtil.isNullableInitialized(var, true)) {
-        nullability = Nullness.NULLABLE;
-      } else if (DfaUtil.isNullableInitialized(var, false)) {
-        nullability = Nullness.NOT_NULL;
-      }
-    }
-
-    myInherentNullability = nullability;
-
-    return nullability;
-  }
-
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/defUse/DefUseInspection.java b/java/java-impl/src/com/intellij/codeInspection/defUse/DefUseInspection.java
index db08293..8b19def 100644
--- a/java/java-impl/src/com/intellij/codeInspection/defUse/DefUseInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/defUse/DefUseInspection.java
@@ -25,211 +25,32 @@
 package com.intellij.codeInspection.defUse;
 
 import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableFix;
-import com.intellij.codeInsight.daemon.impl.quickfix.SideEffectWarningDialog;
-import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
+import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableUtil;
+import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.codeInspection.LocalQuickFix;
+import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.fileEditor.FileEditorManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
-import com.intellij.psi.controlFlow.DefUseUtil;
 import com.intellij.psi.util.PsiExpressionTrimRenderer;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.util.IncorrectOperationException;
-import gnu.trove.THashSet;
-import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
-import javax.swing.*;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import java.awt.*;
-import java.util.*;
+import java.util.ArrayList;
 import java.util.List;
 
-public class DefUseInspection extends BaseLocalInspectionTool {
-  public boolean REPORT_PREFIX_EXPRESSIONS = false;
-  public boolean REPORT_POSTFIX_EXPRESSIONS = true;
-  public boolean REPORT_REDUNDANT_INITIALIZER = true;
-
+public class DefUseInspection extends DefUseInspectionBase {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.defUse.DefUseInspection");
 
-  public static final String DISPLAY_NAME = InspectionsBundle.message("inspection.unused.assignment.display.name");
-  @NonNls public static final String SHORT_NAME = "UnusedAssignment";
-
   @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-      @Override public void visitMethod(PsiMethod method) {
-        checkCodeBlock(method.getBody(), holder, isOnTheFly);
-      }
-
-      @Override public void visitClassInitializer(PsiClassInitializer initializer) {
-        checkCodeBlock(initializer.getBody(), holder, isOnTheFly);
-      }
-    };
+  protected LocalQuickFix createRemoveInitializerFix() {
+    return new RemoveInitializerFix();
   }
 
-  private void checkCodeBlock(final PsiCodeBlock body,
-                              final ProblemsHolder holder,
-                              final boolean isOnTheFly) {
-    if (body == null) return;
-    final Set<PsiVariable> usedVariables = new THashSet<PsiVariable>();
-    List<DefUseUtil.Info> unusedDefs = DefUseUtil.getUnusedDefs(body, usedVariables);
-
-    if (unusedDefs != null && !unusedDefs.isEmpty()) {
-      Collections.sort(unusedDefs, new Comparator<DefUseUtil.Info>() {
-        @Override
-        public int compare(DefUseUtil.Info o1, DefUseUtil.Info o2) {
-          int offset1 = o1.getContext().getTextOffset();
-          int offset2 = o2.getContext().getTextOffset();
-
-          if (offset1 == offset2) return 0;
-          if (offset1 < offset2) return -1;
-
-          return 1;
-        }
-      });
-
-      for (DefUseUtil.Info info : unusedDefs) {
-        PsiElement context = info.getContext();
-        PsiVariable psiVariable = info.getVariable();
-
-        if (context instanceof PsiDeclarationStatement || context instanceof PsiResourceVariable) {
-          if (!info.isRead()) {
-            if (!isOnTheFly) {
-              holder.registerProblem(psiVariable.getNameIdentifier(),
-                                     InspectionsBundle.message("inspection.unused.assignment.problem.descriptor1", "<code>#ref</code> #loc"),
-                                     ProblemHighlightType.LIKE_UNUSED_SYMBOL);
-            }
-          }
-          else {
-            if (REPORT_REDUNDANT_INITIALIZER) {
-              holder.registerProblem(psiVariable.getInitializer(),
-                                     InspectionsBundle.message("inspection.unused.assignment.problem.descriptor2",
-                                                               "<code>" + psiVariable.getName() + "</code>", "<code>#ref</code> #loc"),
-                                     ProblemHighlightType.LIKE_UNUSED_SYMBOL,
-                                     new RemoveInitializerFix());
-            }
-          }
-        }
-        else if (context instanceof PsiAssignmentExpression &&
-                 ((PsiAssignmentExpression)context).getOperationTokenType() == JavaTokenType.EQ) {
-          final PsiAssignmentExpression assignment = (PsiAssignmentExpression)context;
-          holder.registerProblem(assignment.getLExpression(),
-                                 InspectionsBundle.message("inspection.unused.assignment.problem.descriptor3",
-                                                           assignment.getRExpression().getText(), "<code>#ref</code>" + " #loc"), ProblemHighlightType.LIKE_UNUSED_SYMBOL);
-        }
-        else {
-          if (context instanceof PsiPrefixExpression && REPORT_PREFIX_EXPRESSIONS ||
-              context instanceof PsiPostfixExpression && REPORT_POSTFIX_EXPRESSIONS) {
-            holder.registerProblem(context,
-                                   InspectionsBundle.message("inspection.unused.assignment.problem.descriptor4", "<code>#ref</code> #loc"));
-          }
-        }
-      }
-    }
-
-    body.accept(new JavaRecursiveElementWalkingVisitor() {
-      @Override public void visitClass(PsiClass aClass) {
-      }
-
-      @Override public void visitLocalVariable(PsiLocalVariable variable) {
-        if (!usedVariables.contains(variable) && variable.getInitializer() == null && !isOnTheFly) {
-          holder.registerProblem(variable.getNameIdentifier(),
-                                 InspectionsBundle.message("inspection.unused.assignment.problem.descriptor5", "<code>#ref</code> #loc"),
-                                 ProblemHighlightType.LIKE_UNUSED_SYMBOL);
-        }
-      }
-
-      @Override public void visitAssignmentExpression(PsiAssignmentExpression expression) {
-        PsiExpression lExpression = expression.getLExpression();
-        PsiExpression rExpression = expression.getRExpression();
-
-        if (lExpression instanceof PsiReferenceExpression && rExpression instanceof PsiReferenceExpression) {
-          PsiReferenceExpression lRef = (PsiReferenceExpression)lExpression;
-          PsiReferenceExpression rRef = (PsiReferenceExpression)rExpression;
-
-          if (lRef.resolve() != rRef.resolve()) return;
-          PsiExpression lQualifier = lRef.getQualifierExpression();
-          PsiExpression rQualifier = rRef.getQualifierExpression();
-
-          if ((lQualifier == null && rQualifier == null ||
-               lQualifier instanceof PsiThisExpression && rQualifier instanceof PsiThisExpression ||
-               lQualifier instanceof PsiThisExpression && rQualifier == null ||
-               lQualifier == null && rQualifier instanceof PsiThisExpression) && !isOnTheFly) {
-            holder.registerProblem(expression,
-                                   InspectionsBundle.message("inspection.unused.assignment.problem.descriptor6", "<code>#ref</code>"));
-          }
-        }
-      }
-    });
-  }
-
-  @Override
-  public JComponent createOptionsPanel() {
-    return new OptionsPanel();
-  }
-
-  private class OptionsPanel extends JPanel {
-    private final JCheckBox myReportPrefix;
-    private final JCheckBox myReportPostfix;
-    private final JCheckBox myReportInitializer;
-
-    private OptionsPanel() {
-      super(new GridBagLayout());
-
-      GridBagConstraints gc = new GridBagConstraints();
-      gc.weighty = 0;
-      gc.weightx = 1;
-      gc.fill = GridBagConstraints.HORIZONTAL;
-      gc.anchor = GridBagConstraints.NORTHWEST;
-
-      myReportInitializer = new JCheckBox(InspectionsBundle.message("inspection.unused.assignment.option2"));
-      myReportInitializer.setSelected(REPORT_REDUNDANT_INITIALIZER);
-      myReportInitializer.getModel().addChangeListener(new ChangeListener() {
-        @Override
-        public void stateChanged(ChangeEvent e) {
-          REPORT_REDUNDANT_INITIALIZER = myReportInitializer.isSelected();
-        }
-      });
-      gc.insets = new Insets(0, 0, 15, 0);
-      gc.gridy = 0;
-      add(myReportInitializer, gc);
-
-      myReportPrefix = new JCheckBox(InspectionsBundle.message("inspection.unused.assignment.option"));
-      myReportPrefix.setSelected(REPORT_PREFIX_EXPRESSIONS);
-      myReportPrefix.getModel().addChangeListener(new ChangeListener() {
-        @Override
-        public void stateChanged(ChangeEvent e) {
-          REPORT_PREFIX_EXPRESSIONS = myReportPrefix.isSelected();
-        }
-      });
-      gc.insets = new Insets(0, 0, 0, 0);
-      gc.gridy++;
-      add(myReportPrefix, gc);
-
-      myReportPostfix = new JCheckBox(InspectionsBundle.message("inspection.unused.assignment.option1"));
-      myReportPostfix.setSelected(REPORT_POSTFIX_EXPRESSIONS);
-      myReportPostfix.getModel().addChangeListener(new ChangeListener() {
-        @Override
-        public void stateChanged(ChangeEvent e) {
-          REPORT_POSTFIX_EXPRESSIONS = myReportPostfix.isSelected();
-        }
-      });
-
-      gc.weighty = 1;
-      gc.gridy++;
-      add(myReportPostfix, gc);
-    }
-  }
-
-
   private static class RemoveInitializerFix implements LocalQuickFix {
-
     @Override
     @NotNull
     public String getName() {
@@ -246,20 +67,21 @@
       final PsiVariable variable = (PsiVariable)psiInitializer.getParent();
       final PsiDeclarationStatement declaration = (PsiDeclarationStatement)variable.getParent();
       final List<PsiElement> sideEffects = new ArrayList<PsiElement>();
-      boolean hasSideEffects = RemoveUnusedVariableFix.checkSideEffects(psiInitializer, variable, sideEffects);
-      int res = SideEffectWarningDialog.DELETE_ALL;
+      boolean hasSideEffects = RemoveUnusedVariableUtil.checkSideEffects(psiInitializer, variable, sideEffects);
+      int res = RemoveUnusedVariableUtil.DELETE_ALL;
       if (hasSideEffects) {
         hasSideEffects = PsiUtil.isStatement(psiInitializer);
         res = RemoveUnusedVariableFix.showSideEffectsWarning(sideEffects, variable,
                                                              FileEditorManager.getInstance(project).getSelectedTextEditor(),
                                                              hasSideEffects, sideEffects.get(0).getText(),
-                                                             variable.getTypeElement().getText() + " " + variable.getName() + ";<br>" + PsiExpressionTrimRenderer.render((PsiExpression)psiInitializer));
+                                                             variable.getTypeElement().getText() + " " + variable.getName() + ";<br>" + PsiExpressionTrimRenderer
+                                                               .render((PsiExpression)psiInitializer));
       }
       try {
-        if (res == SideEffectWarningDialog.DELETE_ALL) {
+        if (res == RemoveUnusedVariableUtil.DELETE_ALL) {
           psiInitializer.delete();
         }
-        else if (res == SideEffectWarningDialog.MAKE_STATEMENT) {
+        else if (res == RemoveUnusedVariableUtil.MAKE_STATEMENT) {
           final PsiElementFactory factory = JavaPsiFacade.getInstance(variable.getProject()).getElementFactory();
           final PsiStatement statementFromText = factory.createStatementFromText(psiInitializer.getText() + ";", null);
           declaration.getParent().addAfter(statementFromText, declaration);
@@ -277,22 +99,4 @@
       return getName();
     }
   }
-
-  @Override
-  @NotNull
-  public String getDisplayName() {
-    return DISPLAY_NAME;
-  }
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.BUGS_GROUP_NAME;
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return SHORT_NAME;
-  }
 }
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 53f1583..8d7eeaa 100644
--- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java
@@ -17,7 +17,6 @@
 
 import com.intellij.codeInspection.*;
 import com.intellij.ide.fileTemplates.FileTemplate;
-import com.intellij.ide.fileTemplates.FileTemplateManager;
 import com.intellij.ide.fileTemplates.impl.FileTemplateConfigurable;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.options.ShowSettingsUtil;
@@ -29,13 +28,19 @@
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
-import java.util.ArrayList;
-import java.util.Collection;
 
 /**
  * @author cdr
  */
 public class DefaultFileTemplateUsageInspection extends BaseJavaLocalInspectionTool {
+  // Fields are left for the compatibility
+  @Deprecated @SuppressWarnings("UnusedDeclaration")
+  public boolean CHECK_FILE_HEADER = true;
+  @Deprecated @SuppressWarnings("UnusedDeclaration")
+  public boolean CHECK_TRY_CATCH_SECTION = true;
+  @Deprecated @SuppressWarnings("UnusedDeclaration")
+  public boolean CHECK_METHOD_BODY = true;
+
   @Override
   @NotNull
   public String getGroupDisplayName() {
diff --git a/java/java-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java
deleted file mode 100644
index b17f1f5..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.deprecation;
-
-import com.intellij.codeInsight.daemon.JavaErrorMessages;
-import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil;
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.*;
-import com.intellij.psi.infos.MethodCandidateInfo;
-import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.refactoring.util.RefactoringUtil;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-import java.util.List;
-
-/**
- * @author max
- */
-public class DeprecationInspection extends BaseJavaLocalInspectionTool {
-  @NonNls public static final String SHORT_NAME = HighlightInfoType.DEPRECATION_SHORT_NAME;
-  @NonNls public static final String ID = HighlightInfoType.DEPRECATION_ID;
-  public static final String DISPLAY_NAME = HighlightInfoType.DEPRECATION_DISPLAY_NAME;
-
-  public boolean IGNORE_INSIDE_DEPRECATED = false;
-  public boolean IGNORE_ABSTRACT_DEPRECATED_OVERRIDES = true;
-  public boolean IGNORE_IMPORT_STATEMENTS = true;
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-    return new DeprecationElementVisitor(holder, IGNORE_INSIDE_DEPRECATED, IGNORE_ABSTRACT_DEPRECATED_OVERRIDES, IGNORE_IMPORT_STATEMENTS);
-  }
-
-  @Override
-  @NotNull
-  public String getDisplayName() {
-    return DISPLAY_NAME;
-  }
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return "";
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return SHORT_NAME;
-  }
-
-  @Override
-  @NotNull
-  @NonNls
-  public String getID() {
-    return ID;
-  }
-
-  @Override
-  public boolean isEnabledByDefault() {
-    return true;
-  }
-
-  @Override
-  public JComponent createOptionsPanel() {
-    final MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this);
-    panel.addCheckbox("Ignore inside deprecated members", "IGNORE_INSIDE_DEPRECATED");
-    panel.addCheckbox("Ignore inside non-static imports", "IGNORE_IMPORT_STATEMENTS");
-    panel.addCheckbox("<html>Ignore overrides of deprecated abstract methods from non-deprecated supers</html>", "IGNORE_ABSTRACT_DEPRECATED_OVERRIDES");
-    return panel;
-
-  }
-
-  private static class DeprecationElementVisitor extends JavaElementVisitor {
-    private final ProblemsHolder myHolder;
-    private final boolean myIgnoreInsideDeprecated;
-    private final boolean myIgnoreAbstractDeprecatedOverrides;
-    private final boolean myIgnoreImportStatements;
-
-    public DeprecationElementVisitor(final ProblemsHolder holder,
-                                     boolean ignoreInsideDeprecated,
-                                     boolean ignoreAbstractDeprecatedOverrides,
-                                     boolean ignoreImportStatements) {
-      myHolder = holder;
-      myIgnoreInsideDeprecated = ignoreInsideDeprecated;
-      myIgnoreAbstractDeprecatedOverrides = ignoreAbstractDeprecatedOverrides;
-      myIgnoreImportStatements = ignoreImportStatements;
-    }
-
-    @Override
-    public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
-      JavaResolveResult result = reference.advancedResolve(true);
-      PsiElement resolved = result.getElement();
-      checkDeprecated(resolved, reference.getReferenceNameElement(), null, myIgnoreInsideDeprecated, myIgnoreImportStatements, myHolder);
-    }
-
-    @Override
-    public void visitImportStaticStatement(PsiImportStaticStatement statement) {
-      final PsiJavaCodeReferenceElement importReference = statement.getImportReference();
-      if (importReference != null) {
-        checkDeprecated(importReference.resolve(), importReference.getReferenceNameElement(), null, myIgnoreInsideDeprecated, false, myHolder);
-      }
-    }
-
-    @Override public void visitReferenceExpression(PsiReferenceExpression expression) {
-      visitReferenceElement(expression);
-    }
-
-    @Override public void visitNewExpression(PsiNewExpression expression) {
-      PsiType type = expression.getType();
-      PsiExpressionList list = expression.getArgumentList();
-      if (!(type instanceof PsiClassType)) return;
-      PsiClassType.ClassResolveResult typeResult = ((PsiClassType)type).resolveGenerics();
-      PsiClass aClass = typeResult.getElement();
-      if (aClass == null) return;
-      if (aClass instanceof PsiAnonymousClass) {
-        type = ((PsiAnonymousClass)aClass).getBaseClassType();
-        typeResult = ((PsiClassType)type).resolveGenerics();
-        aClass = typeResult.getElement();
-        if (aClass == null) return;
-      }
-      final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(expression.getProject()).getResolveHelper();
-      final PsiMethod[] constructors = aClass.getConstructors();
-      if (constructors.length > 0 && list != null) {
-        JavaResolveResult[] results = resolveHelper.multiResolveConstructor((PsiClassType)type, list, list);
-        MethodCandidateInfo result = null;
-        if (results.length == 1) result = (MethodCandidateInfo)results[0];
-
-        PsiMethod constructor = result == null ? null : result.getElement();
-        if (constructor != null && expression.getClassOrAnonymousClassReference() != null) {
-          if (expression.getClassReference() == null && constructor.getParameterList().getParametersCount() == 0) return;
-          checkDeprecated(constructor, expression.getClassOrAnonymousClassReference(), null, myIgnoreInsideDeprecated, myIgnoreImportStatements, myHolder);
-        }
-      }
-    }
-
-    @Override public void visitMethod(PsiMethod method){
-        MethodSignatureBackedByPsiMethod methodSignature = MethodSignatureBackedByPsiMethod.create(method, PsiSubstitutor.EMPTY);
-        if (!method.isConstructor()) {
-          List<MethodSignatureBackedByPsiMethod> superMethodSignatures = method.findSuperMethodSignaturesIncludingStatic(true);
-          checkMethodOverridesDeprecated(methodSignature, superMethodSignatures, myIgnoreAbstractDeprecatedOverrides, myHolder);
-        } else {
-          checkImplicitCallToSuper(method);
-        }
-    }
-
-    private void checkImplicitCallToSuper(PsiMethod method) {
-      final PsiClass containingClass = method.getContainingClass();
-      assert containingClass != null;
-      final PsiClass superClass = containingClass.getSuperClass();
-      if (hasDefaultDeprecatedConstructor(superClass)) {
-        if (superClass instanceof PsiAnonymousClass) {
-          final PsiExpressionList argumentList = ((PsiAnonymousClass)superClass).getArgumentList();
-          if (argumentList != null && argumentList.getExpressions().length > 0) return;
-        }
-        final PsiCodeBlock body = method.getBody();
-        if (body != null) {
-          final PsiStatement[] statements = body.getStatements();
-          if (statements.length == 0 || !RefactoringUtil.isSuperOrThisCall(statements[0], true, true)) {
-            registerDefaultConstructorProblem(superClass, method.getNameIdentifier(), false);
-          }
-        }
-      }
-    }
-
-    private void registerDefaultConstructorProblem(PsiClass superClass, PsiElement nameIdentifier, boolean asDeprecated) {
-      myHolder.registerProblem(nameIdentifier, "Default constructor in " + superClass.getQualifiedName() + " is deprecated",
-                               asDeprecated ? ProblemHighlightType.LIKE_DEPRECATED : ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
-    }
-
-    @Override
-    public void visitClass(PsiClass aClass) {
-      final PsiMethod[] currentConstructors = aClass.getConstructors();
-      if (currentConstructors.length == 0) {
-        final PsiClass superClass = aClass.getSuperClass();
-        if (hasDefaultDeprecatedConstructor(superClass)) {
-          final boolean isAnonymous = aClass instanceof PsiAnonymousClass;
-          if (isAnonymous) {
-            final PsiExpressionList argumentList = ((PsiAnonymousClass)aClass).getArgumentList();
-            if (argumentList != null && argumentList.getExpressions().length > 0) return;
-          }
-          registerDefaultConstructorProblem(superClass, isAnonymous ? ((PsiAnonymousClass)aClass).getBaseClassReference() : aClass.getNameIdentifier(), isAnonymous);
-        }
-      }
-    }
-  }
-
-  private static boolean hasDefaultDeprecatedConstructor(PsiClass superClass) {
-    if (superClass != null) {
-      final PsiMethod[] constructors = superClass.getConstructors();
-      for (PsiMethod constructor : constructors) {
-        if (constructor.getParameterList().getParametersCount() == 0 && constructor.isDeprecated()) {
-          return true;
-        }
-      }
-    }
-    return false;
-  }
-
-  //@top
-  static void checkMethodOverridesDeprecated(MethodSignatureBackedByPsiMethod methodSignature,
-                                             List<MethodSignatureBackedByPsiMethod> superMethodSignatures,
-                                             boolean ignoreAbstractDeprecatedOverrides, ProblemsHolder holder) {
-    PsiMethod method = methodSignature.getMethod();
-    PsiElement methodName = method.getNameIdentifier();
-    for (MethodSignatureBackedByPsiMethod superMethodSignature : superMethodSignatures) {
-      PsiMethod superMethod = superMethodSignature.getMethod();
-      PsiClass aClass = superMethod.getContainingClass();
-      if (aClass == null) continue;
-      // do not show deprecated warning for class implementing deprecated methods
-      if (ignoreAbstractDeprecatedOverrides && !aClass.isDeprecated() && superMethod.hasModifierProperty(PsiModifier.ABSTRACT)) continue;
-      if (superMethod.isDeprecated()) {
-        String description = JavaErrorMessages.message("overrides.deprecated.method",
-                                                       HighlightMessageUtil.getSymbolName(aClass, PsiSubstitutor.EMPTY));
-        holder.registerProblem(methodName, description, ProblemHighlightType.LIKE_DEPRECATED);
-      }
-    }
-  }
-
-  public static void checkDeprecated(PsiElement refElement,
-                                     PsiElement elementToHighlight,
-                                     @Nullable TextRange rangeInElement,
-                                     ProblemsHolder holder) {
-    checkDeprecated(refElement, elementToHighlight, rangeInElement, false, false, holder);
-  }
-
-  public static void checkDeprecated(PsiElement refElement,
-                                     PsiElement elementToHighlight,
-                                     @Nullable TextRange rangeInElement,
-                                     boolean ignoreInsideDeprecated,
-                                     boolean ignoreImportStatements,
-                                     ProblemsHolder holder) {
-    if (!(refElement instanceof PsiDocCommentOwner)) return;
-    if (!((PsiDocCommentOwner)refElement).isDeprecated()) return;
-
-    if (ignoreInsideDeprecated) {
-      PsiElement parent = elementToHighlight;
-      while ((parent = PsiTreeUtil.getParentOfType(parent, PsiDocCommentOwner.class, true)) != null) {
-        if (((PsiDocCommentOwner)parent).isDeprecated()) return;
-      }
-    }
-
-    if (ignoreImportStatements && PsiTreeUtil.getParentOfType(elementToHighlight, PsiImportStatementBase.class) != null) {
-      return;
-    }
-
-    String description = JavaErrorMessages.message("deprecated.symbol",
-                                                   HighlightMessageUtil.getSymbolName(refElement, PsiSubstitutor.EMPTY));
-
-    holder.registerProblem(elementToHighlight, description, ProblemHighlightType.LIKE_DEPRECATED, rangeInElement);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/duplicateThrows/DuplicateThrowsInspection.java b/java/java-impl/src/com/intellij/codeInspection/duplicateThrows/DuplicateThrowsInspection.java
deleted file mode 100644
index b01d105..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/duplicateThrows/DuplicateThrowsInspection.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.duplicateThrows;
-
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInspection.DeleteThrowsFix;
-import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
-import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
-import com.intellij.psi.*;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-
-public class DuplicateThrowsInspection extends BaseLocalInspectionTool {
-
-  @SuppressWarnings("PublicField")
-  public boolean ignoreSubclassing = false;
-
-  @Override
-  @NotNull
-  public String getDisplayName() {
-    return InspectionsBundle.message("inspection.duplicate.throws.display.name");
-  }
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.DECLARATION_REDUNDANCY;
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return "DuplicateThrows";
-  }
-
-  @Nullable
-  @Override
-  public JComponent createOptionsPanel() {
-    return new SingleCheckboxOptionsPanel(
-      InspectionsBundle.message("inspection.duplicate.throws.ignore.subclassing.option"), this, "ignoreSubclassing");
-  }
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-
-      @Override public void visitMethod(PsiMethod method) {
-        PsiReferenceList throwsList = method.getThrowsList();
-        PsiJavaCodeReferenceElement[] refs = throwsList.getReferenceElements();
-        PsiClassType[] types = throwsList.getReferencedTypes();
-        for (int i = 0; i < types.length; i++) {
-          PsiClassType type = types[i];
-          for (int j = i+1; j < types.length; j++) {
-            PsiClassType otherType = types[j];
-            String problem = null;
-            PsiJavaCodeReferenceElement ref = refs[i];
-            if (type.equals(otherType)) {
-              problem = InspectionsBundle.message("inspection.duplicate.throws.problem");
-            }
-            else if (!ignoreSubclassing) {
-              if (otherType.isAssignableFrom(type)) {
-                problem = InspectionsBundle.message("inspection.duplicate.throws.more.general.problem", otherType.getCanonicalText());
-              }
-              else if (type.isAssignableFrom(otherType)) {
-                problem = InspectionsBundle.message("inspection.duplicate.throws.more.general.problem", type.getCanonicalText());
-                ref = refs[j];
-                type = otherType;
-              }
-            }
-            if (problem != null) {
-              holder.registerProblem(ref, problem, ProblemHighlightType.LIKE_UNUSED_SYMBOL, new DeleteThrowsFix(method, type));
-            }
-          }
-        }
-      }
-    };
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java b/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java
index e6a6608..08f1e42 100644
--- a/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java
@@ -23,6 +23,7 @@
 import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.reference.*;
 import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
+import com.intellij.codeInspection.util.SpecialAnnotationsUtilBase;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.extensions.Extensions;
@@ -134,10 +135,10 @@
     if (message != null) {
       final ArrayList<LocalQuickFix> fixes = new ArrayList<LocalQuickFix>();
       fixes.add(getFix(processor, needToDeleteHierarchy));
-      SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes(refMethod.getElement(), new Processor<String>() {
+      SpecialAnnotationsUtilBase.createAddToSpecialAnnotationFixes(refMethod.getElement(), new Processor<String>() {
         @Override
         public boolean process(final String qualifiedName) {
-          fixes.add(SpecialAnnotationsUtil.createAddToSpecialAnnotationsListQuickFix(
+          fixes.add(SpecialAnnotationsUtilBase.createAddToSpecialAnnotationsListQuickFix(
             QuickFixBundle.message("fix.add.special.annotation.text", qualifiedName),
             QuickFixBundle.message("fix.add.special.annotation.family"),
             EXCLUDE_ANNOS, qualifiedName, refMethod.getElement()));
diff --git a/java/java-impl/src/com/intellij/codeInspection/inheritance/ChangeSuperClassFix.java b/java/java-impl/src/com/intellij/codeInspection/inheritance/ChangeSuperClassFix.java
deleted file mode 100644
index 22631e2..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/inheritance/ChangeSuperClassFix.java
+++ /dev/null
@@ -1,128 +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.inheritance;
-
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInsight.intention.LowPriorityAction;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.command.WriteCommandAction;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.TestOnly;
-
-/**
- * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
- */
-public class ChangeSuperClassFix implements LocalQuickFix {
-  @NotNull
-  private final PsiClass myNewSuperClass;
-  @NotNull
-  private final PsiClass myOldSuperClass;
-  private final int myPercent;
-
-  public ChangeSuperClassFix(@NotNull final PsiClass newSuperClass, final int percent, @NotNull final PsiClass oldSuperClass) {
-    myNewSuperClass = newSuperClass;
-    myOldSuperClass = oldSuperClass;
-    myPercent = percent;
-  }
-
-  @NotNull
-  @TestOnly
-  public PsiClass getNewSuperClass() {
-    return myNewSuperClass;
-  }
-
-  @TestOnly
-  public int getPercent() {
-    return myPercent;
-  }
-
-  @NotNull
-  @Override
-  public String getName() {
-    return String.format("Make extends '%s' - %s%%", myNewSuperClass.getQualifiedName(), myPercent);
-  }
-
-  @NotNull
-  @Override
-  public String getFamilyName() {
-    return GroupNames.INHERITANCE_GROUP_NAME;
-  }
-
-  @Override
-  public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor problemDescriptor) {
-    changeSuperClass((PsiClass)problemDescriptor.getPsiElement(), myOldSuperClass, myNewSuperClass);
-  }
-
-  /**
-   * myOldSuperClass and myNewSuperClass can be interfaces or classes in any combination
-   * <p/>
-   * 1. not checks that myOldSuperClass is really super of aClass
-   * 2. not checks that myNewSuperClass not exists in currently existed supers
-   */
-  private static void changeSuperClass(@NotNull final PsiClass aClass,
-                                       @NotNull final PsiClass oldSuperClass,
-                                       @NotNull final PsiClass newSuperClass) {
-    if (!FileModificationService.getInstance().preparePsiElementForWrite(aClass)) return;
-
-    new WriteCommandAction.Simple(newSuperClass.getProject(), aClass.getContainingFile()) {
-      @Override
-      protected void run() throws Throwable {
-        PsiElementFactory factory = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory();
-        if (aClass instanceof PsiAnonymousClass) {
-          ((PsiAnonymousClass)aClass).getBaseClassReference().replace(factory.createClassReferenceElement(newSuperClass));
-        }
-        else if (oldSuperClass.isInterface()) {
-          final PsiReferenceList interfaceList = aClass.getImplementsList();
-          if (interfaceList != null) {
-            for (final PsiJavaCodeReferenceElement interfaceRef : interfaceList.getReferenceElements()) {
-              final PsiElement aInterface = interfaceRef.resolve();
-              if (aInterface != null && aInterface.isEquivalentTo(oldSuperClass)) {
-                interfaceRef.delete();
-              }
-            }
-          }
-
-          final PsiReferenceList extendsList = aClass.getExtendsList();
-          if (extendsList != null) {
-            final PsiJavaCodeReferenceElement newClassReference = factory.createClassReferenceElement(newSuperClass);
-            if (extendsList.getReferenceElements().length == 0) {
-              extendsList.add(newClassReference);
-            }
-          }
-        }
-        else {
-          final PsiReferenceList extendsList = aClass.getExtendsList();
-          if (extendsList != null && extendsList.getReferenceElements().length == 1) {
-            extendsList.getReferenceElements()[0].delete();
-            PsiElement ref = extendsList.add(factory.createClassReferenceElement(newSuperClass));
-            JavaCodeStyleManager.getInstance(aClass.getProject()).shortenClassReferences(ref);
-          }
-        }
-      }
-    }.execute();
-  }
-
-  public static class LowPriority extends ChangeSuperClassFix implements LowPriorityAction {
-    public LowPriority(@NotNull final PsiClass newSuperClass, final int percent, @NotNull final PsiClass oldSuperClass) {
-      super(newSuperClass, percent, oldSuperClass);
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/inheritance/SuperClassHasFrequentlyUsedInheritorsInspection.java b/java/java-impl/src/com/intellij/codeInspection/inheritance/SuperClassHasFrequentlyUsedInheritorsInspection.java
deleted file mode 100644
index aa3dd1e..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/inheritance/SuperClassHasFrequentlyUsedInheritorsInspection.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package com.intellij.codeInspection.inheritance;
-
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.inheritance.search.InheritorsStatisticalDataSearch;
-import com.intellij.codeInspection.inheritance.search.InheritorsStatisticsSearchResult;
-import com.intellij.psi.*;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
- */
-public class SuperClassHasFrequentlyUsedInheritorsInspection extends BaseJavaLocalInspectionTool {
-  private final static int MIN_PERCENT_RATIO = 5;
-  public final static int MAX_QUICK_FIX_COUNTS = 4;
-
-  @Nls
-  @NotNull
-  @Override
-  public String getGroupDisplayName() {
-    return GroupNames.INHERITANCE_GROUP_NAME;
-  }
-
-  @Nls
-  @NotNull
-  @Override
-  public String getDisplayName() {
-    return "Class may extend a commonly used base class instead of implementing interface or extending abstract class";
-  }
-
-  @Override
-  public boolean isEnabledByDefault() {
-    return true;
-  }
-
-  @Nullable
-  @Override
-  public ProblemDescriptor[] checkClass(@NotNull final PsiClass aClass,
-                                        @NotNull final InspectionManager manager,
-                                        final boolean isOnTheFly) {
-    if (aClass.isInterface() ||
-        aClass instanceof PsiTypeParameter ||
-        aClass.getMethods().length != 0 ||
-        aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
-      return null;
-    }
-
-    final PsiClass superClass = getSuperIfUnique(aClass);
-    if (superClass == null) return null;
-
-    final List<InheritorsStatisticsSearchResult> topInheritors =
-      InheritorsStatisticalDataSearch.search(superClass, aClass, aClass.getResolveScope(), MIN_PERCENT_RATIO);
-
-    if (topInheritors.isEmpty()) {
-      return null;
-    }
-
-    final Collection<LocalQuickFix> topInheritorsQuickFix = new ArrayList<LocalQuickFix>(topInheritors.size());
-
-    boolean isFirst = true;
-    for (final InheritorsStatisticsSearchResult searchResult : topInheritors) {
-      final LocalQuickFix quickFix;
-      if (isFirst) {
-        quickFix = new ChangeSuperClassFix(searchResult.getPsiClass(), searchResult.getPercent(), superClass);
-        isFirst = false;
-      } else {
-        quickFix = new ChangeSuperClassFix.LowPriority(searchResult.getPsiClass(), searchResult.getPercent(), superClass);
-      }
-      topInheritorsQuickFix.add(quickFix);
-      if (topInheritorsQuickFix.size() >= MAX_QUICK_FIX_COUNTS) {
-        break;
-      }
-    }
-    return new ProblemDescriptor[]{manager
-      .createProblemDescriptor(aClass, "Class may extend a commonly used base class instead of implementing interface or extending abstract class", false,
-                               topInheritorsQuickFix.toArray(new LocalQuickFix[topInheritorsQuickFix.size()]),
-                               ProblemHighlightType.INFORMATION)};
-  }
-
-  @Nullable
-  private static PsiClass getSuperIfUnique(final @NotNull PsiClass aClass) {
-    if (aClass instanceof PsiAnonymousClass) {
-      return (PsiClass)((PsiAnonymousClass)aClass).getBaseClassReference().resolve();
-    }
-    final PsiReferenceList extendsList = aClass.getExtendsList();
-    if (extendsList != null) {
-      final PsiJavaCodeReferenceElement[] referenceElements = extendsList.getReferenceElements();
-      if (referenceElements.length == 1) {
-        PsiClass returnClass = (PsiClass)referenceElements[0].resolve();
-        if (returnClass != null &&
-            !CommonClassNames.JAVA_LANG_OBJECT.equals(returnClass.getQualifiedName()) &&
-            !returnClass.isInterface()) {
-          return returnClass;
-        }
-      }
-    }
-
-    final PsiReferenceList implementsList = aClass.getImplementsList();
-    if (implementsList != null) {
-      final PsiJavaCodeReferenceElement[] referenceElements = implementsList.getReferenceElements();
-      if (referenceElements.length == 1) {
-        PsiClass returnClass = (PsiClass)referenceElements[0].resolve();
-        if (returnClass != null && returnClass.isInterface()) {
-          return returnClass;
-        }
-      }
-    }
-    return null;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/inheritance/search/InheritorsCountData.java b/java/java-impl/src/com/intellij/codeInspection/inheritance/search/InheritorsCountData.java
deleted file mode 100644
index 18f6587..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/inheritance/search/InheritorsCountData.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.intellij.codeInspection.inheritance.search;
-
-import com.intellij.psi.PsiClass;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
- */
-class InheritorsCountData implements Comparable<InheritorsCountData> {
-  @NotNull
-  private final PsiClass myPsiClass;
-  private final int myInheritorsCount;
-
-  public InheritorsCountData(@NotNull final PsiClass psiClass, final int inheritorsCount) {
-    myPsiClass = psiClass;
-    myInheritorsCount = inheritorsCount;
-  }
-
-  @Override
-  public boolean equals(final Object o) {
-    if (this == o) return true;
-    if (o == null || !(o instanceof InheritorsCountData)) return false;
-
-    final InheritorsCountData data = (InheritorsCountData)o;
-    return myInheritorsCount == data.myInheritorsCount && myPsiClass.equals(data.myPsiClass);
-  }
-
-  @NotNull
-  public PsiClass getPsiClass() {
-    return myPsiClass;
-  }
-
-  public int getInheritorsCount() {
-    return myInheritorsCount;
-  }
-
-  @Override
-  public int hashCode() {
-    final String name = myPsiClass.getName();
-    int result = name != null ? name.hashCode() : 0;
-    return 31 * result + myInheritorsCount;
-  }
-
-  @Override
-  public int compareTo(@NotNull final InheritorsCountData that) {
-    final int sub = -this.myInheritorsCount + that.myInheritorsCount;
-    if (sub != 0) return sub;
-    return String.CASE_INSENSITIVE_ORDER.compare(this.myPsiClass.getName(), that.myPsiClass.getName());
-  }
-
-  public String toString() {
-    return String.format("%s:%d", myPsiClass, myInheritorsCount);
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInspection/inheritance/search/InheritorsStatisticalDataSearch.java b/java/java-impl/src/com/intellij/codeInspection/inheritance/search/InheritorsStatisticalDataSearch.java
deleted file mode 100644
index 8691d6b..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/inheritance/search/InheritorsStatisticalDataSearch.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package com.intellij.codeInspection.inheritance.search;
-
-import com.intellij.openapi.util.Pair;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.search.searches.DirectClassInheritorsSearch;
-import com.intellij.util.Processor;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.*;
-
-/**
- * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
- */
-public class InheritorsStatisticalDataSearch {
-
-  /**
-   * search for most used inheritors of superClass in scope
-   *
-   * @param aClass          - class that excluded from inheritors of superClass
-   * @param minPercentRatio - head volume
-   * @return - search results in relevant ordering (frequency descent)
-   */
-  public static List<InheritorsStatisticsSearchResult> search(final @NotNull PsiClass superClass,
-                                          final @NotNull PsiClass aClass,
-                                          final @NotNull GlobalSearchScope scope,
-                                          final int minPercentRatio) {
-    final String superClassName = superClass.getName();
-    final String aClassName = aClass.getName();
-    final Set<String> disabledNames = new HashSet<String>();
-    disabledNames.add(aClassName);
-    disabledNames.add(superClassName);
-    final Set<InheritorsCountData> collector = new TreeSet<InheritorsCountData>();
-    final Pair<Integer, Integer> collectingResult = collectInheritorsInfo(superClass, collector, disabledNames);
-    final int allAnonymousInheritors = collectingResult.getSecond();
-    final int allInheritors = collectingResult.getFirst() + allAnonymousInheritors - 1;
-
-    final List<InheritorsStatisticsSearchResult> result = new ArrayList<InheritorsStatisticsSearchResult>();
-
-    Integer firstPercent = null;
-    for (final InheritorsCountData data : collector) {
-      final int inheritorsCount = data.getInheritorsCount();
-      if (inheritorsCount < allAnonymousInheritors) {
-        break;
-      }
-      final int percent = (inheritorsCount * 100) / allInheritors;
-      if (percent < 1) {
-        break;
-      }
-      if (firstPercent == null) {
-        firstPercent = percent;
-      }
-      else if (percent * minPercentRatio < firstPercent) {
-        break;
-      }
-
-      final PsiClass psiClass = data.getPsiClass();
-      final VirtualFile file = psiClass.getContainingFile().getVirtualFile();
-      if (file != null && scope.contains(file)) {
-        result.add(new InheritorsStatisticsSearchResult(psiClass, percent));
-      }
-    }
-    return result;
-  }
-
-  private static Pair<Integer, Integer> collectInheritorsInfo(final PsiClass superClass,
-                                                              final Set<InheritorsCountData> collector,
-                                                              final Set<String> disabledNames) {
-    return collectInheritorsInfo(superClass, collector, disabledNames, new HashSet<String>(), new HashSet<String>());
-  }
-
-  private static Pair<Integer, Integer> collectInheritorsInfo(final PsiClass aClass,
-                                                              final Set<InheritorsCountData> collector,
-                                                              final Set<String> disabledNames,
-                                                              final Set<String> processedElements,
-                                                              final Set<String> allNotAnonymousInheritors) {
-    final String className = aClass.getName();
-    if (!processedElements.add(className)) return Pair.create(0, 0);
-
-    final MyInheritorsInfoProcessor processor = new MyInheritorsInfoProcessor(collector, disabledNames, processedElements);
-    DirectClassInheritorsSearch.search(aClass).forEach(processor);
-
-    allNotAnonymousInheritors.addAll(processor.getAllNotAnonymousInheritors());
-
-    final int allInheritorsCount = processor.getAllNotAnonymousInheritors().size() + processor.getAnonymousInheritorsCount();
-    if (!aClass.isInterface() && allInheritorsCount != 0 && !disabledNames.contains(className)) {
-      collector.add(new InheritorsCountData(aClass, allInheritorsCount));
-    }
-    return Pair.create(allNotAnonymousInheritors.size(), processor.getAnonymousInheritorsCount());
-  }
-
-  private static class MyInheritorsInfoProcessor implements Processor<PsiClass> {
-    private final Set<InheritorsCountData> myCollector;
-    private final Set<String> myDisabledNames;
-    private final Set<String> myProcessedElements;
-    private final Set<String> myAllNotAnonymousInheritors;
-
-    private MyInheritorsInfoProcessor(Set<InheritorsCountData> collector, Set<String> disabledNames, Set<String> processedElements) {
-      myCollector = collector;
-      myDisabledNames = disabledNames;
-      myProcessedElements = processedElements;
-      myAllNotAnonymousInheritors = new HashSet<String>();
-    }
-
-    private int myAnonymousInheritorsCount = 0;
-
-    private Set<String> getAllNotAnonymousInheritors() {
-      return myAllNotAnonymousInheritors;
-    }
-
-    private int getAnonymousInheritorsCount() {
-      return myAnonymousInheritorsCount;
-    }
-
-    @Override
-    public boolean process(final PsiClass psiClass) {
-      final String inheritorName = psiClass.getName();
-      if (inheritorName == null) {
-        myAnonymousInheritorsCount++;
-      }
-      else {
-        final Pair<Integer, Integer> res =
-          collectInheritorsInfo(psiClass, myCollector, myDisabledNames, myProcessedElements, myAllNotAnonymousInheritors);
-        myAnonymousInheritorsCount += res.getSecond();
-        if (!psiClass.isInterface()) {
-          myAllNotAnonymousInheritors.add(inheritorName);
-        }
-      }
-      return true;
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/inheritance/search/InheritorsStatisticsSearchResult.java b/java/java-impl/src/com/intellij/codeInspection/inheritance/search/InheritorsStatisticsSearchResult.java
deleted file mode 100644
index 2d832bd..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/inheritance/search/InheritorsStatisticsSearchResult.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.intellij.codeInspection.inheritance.search;
-
-import com.intellij.psi.PsiClass;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author Dmitry Batkovich
- */
-public class InheritorsStatisticsSearchResult {
-
-  @NotNull
-  private final PsiClass myClass;
-  private final int myPercent;
-
-  InheritorsStatisticsSearchResult(final @NotNull PsiClass aClass, final int percent) {
-    myClass = aClass;
-    myPercent = percent;
-  }
-
-  public PsiClass getPsiClass() {
-    return myClass;
-  }
-
-  public int getPercent() {
-    return myPercent;
-  }
-
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/nullable/AnnotateOverriddenMethodParameterFix.java b/java/java-impl/src/com/intellij/codeInspection/nullable/AnnotateOverriddenMethodParameterFix.java
deleted file mode 100644
index 56cd621..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/nullable/AnnotateOverriddenMethodParameterFix.java
+++ /dev/null
@@ -1,101 +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.nullable;
-
-import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.intention.AddAnnotationFix;
-import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiParameter;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.search.searches.OverridingMethodsSearch;
-import com.intellij.psi.util.ClassUtil;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author cdr
- */
-public class AnnotateOverriddenMethodParameterFix implements LocalQuickFix {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.AnnotateMethodFix");
-  private final String myAnnotation;
-  private final String[] myAnnosToRemove;
-
-  public AnnotateOverriddenMethodParameterFix(final String fqn, String... annosToRemove) {
-    myAnnotation = fqn;
-    myAnnosToRemove = annosToRemove;
-  }
-
-  @Override
-  @NotNull
-  public String getName() {
-    return InspectionsBundle.message("annotate.overridden.methods.parameters", ClassUtil.extractClassName(myAnnotation));
-  }
-
-  @Override
-  public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-    final PsiElement psiElement = descriptor.getPsiElement();
-
-    PsiParameter parameter = PsiTreeUtil.getParentOfType(psiElement, PsiParameter.class, false);
-    if (parameter == null) return;
-    PsiMethod method = PsiTreeUtil.getParentOfType(parameter, PsiMethod.class);
-    if (method == null) return;
-    PsiParameter[] parameters = method.getParameterList().getParameters();
-    int index = ArrayUtil.find(parameters, parameter);
-
-    List<PsiParameter> toAnnotate = new ArrayList<PsiParameter>();
-
-    PsiMethod[] methods = OverridingMethodsSearch.search(method, GlobalSearchScope.allScope(project), true).toArray(PsiMethod.EMPTY_ARRAY);
-    for (PsiMethod psiMethod : methods) {
-      PsiParameter[] psiParameters = psiMethod.getParameterList().getParameters();
-      if (index >= psiParameters.length) continue;
-      PsiParameter psiParameter = psiParameters[index];
-      if (!AnnotationUtil.isAnnotated(psiParameter, myAnnotation, false, false) && psiMethod.getManager().isInProject(psiMethod)) {
-        toAnnotate.add(psiParameter);
-      }
-    }
-
-    FileModificationService.getInstance().preparePsiElementsForWrite(toAnnotate);
-    for (PsiParameter psiParam : toAnnotate) {
-      try {
-        assert psiParam != null : toAnnotate;
-        if (AnnotationUtil.isAnnotatingApplicable(psiParam, myAnnotation)) {
-          new AddAnnotationFix(myAnnotation, psiParam, myAnnosToRemove).invoke(project, null, psiParam.getContainingFile());
-        }
-      }
-      catch (IncorrectOperationException e) {
-        LOG.error(e);
-      }
-    }
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return getName();
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/nullable/ChangeNullableDefaultsFix.java b/java/java-impl/src/com/intellij/codeInspection/nullable/ChangeNullableDefaultsFix.java
deleted file mode 100644
index 53b439f..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/nullable/ChangeNullableDefaultsFix.java
+++ /dev/null
@@ -1,66 +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.nullable;
-
-import com.intellij.codeInsight.NullableNotNullManager;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiAnnotation;
-import org.jetbrains.annotations.NotNull;
-
-/**
-* User: anna
-* Date: 2/22/13
-*/
-class ChangeNullableDefaultsFix implements LocalQuickFix {
-  private final NullableNotNullManager myManager;
-  private final String myNotNullName;
-  private final String myNullableName;
-
-  public ChangeNullableDefaultsFix(PsiAnnotation notNull, PsiAnnotation nullable, NullableNotNullManager manager) {
-    myNotNullName = notNull != null ? notNull.getQualifiedName() : null;
-    myNullableName = nullable != null ? nullable.getQualifiedName() : null;
-    myManager = manager;
-  }
-
-  ChangeNullableDefaultsFix(String notNull, String nullable, NullableNotNullManager manager) {
-    myManager = manager;
-    myNotNullName = notNull;
-    myNullableName = nullable;
-  }
-
-  @NotNull
-  @Override
-  public String getName() {
-    return "Make \"" + (myNotNullName != null ? myNotNullName : myNullableName) + "\" default annotation";
-  }
-
-  @NotNull
-  @Override
-  public String getFamilyName() {
-    return getName();
-  }
-
-  @Override
-  public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-    if (myNotNullName != null) {
-      myManager.setDefaultNotNull(myNotNullName);
-    } else {
-      myManager.setDefaultNullable(myNullableName);
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspection.java b/java/java-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspection.java
index bc9195d..7e8448e 100644
--- a/java/java-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspection.java
@@ -15,474 +15,23 @@
  */
 package com.intellij.codeInspection.nullable;
 
-import com.intellij.codeInsight.AnnotationUtil;
 import com.intellij.codeInsight.NullableNotNullDialog;
-import com.intellij.codeInsight.NullableNotNullManager;
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInsight.intention.AddAnnotationFix;
-import com.intellij.codeInsight.intention.impl.AddNotNullAnnotationFix;
-import com.intellij.codeInsight.intention.impl.AddNullableAnnotationFix;
-import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
 import com.intellij.ide.DataManager;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectManager;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.codeStyle.VariableKind;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.search.LocalSearchScope;
-import com.intellij.psi.search.searches.OverridingMethodsSearch;
-import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.psi.util.*;
-import com.intellij.refactoring.psi.PropertyUtils;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.Processor;
-import com.intellij.util.containers.ContainerUtil;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.util.List;
 
-public class NullableStuffInspection extends BaseLocalInspectionTool {
-  // deprecated fields remain to minimize changes to users inspection profiles (which are often located in version control).
-  @Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NULLABLE_METHOD_OVERRIDES_NOTNULL = true;
-  @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL = true;
-  @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOTNULL_PARAMETER_OVERRIDES_NULLABLE = true;
-  @Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_PARAMETER_OVERRIDES_NOTNULL = true;
-  @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_GETTER = true;
-  @Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_SETTER_PARAMETER = true;
-  @Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = true; // remains for test
-  @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NULLS_PASSED_TO_NON_ANNOTATED_METHOD = true;
-
-  private static final Logger LOG = Logger.getInstance("#" + NullableStuffInspection.class.getName());
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-      @Override public void visitMethod(PsiMethod method) {
-        if (!PsiUtil.isLanguageLevel5OrHigher(method)) return;
-        checkNullableStuffForMethod(method, holder);
-      }
-
-      @Override public void visitField(PsiField field) {
-        if (!PsiUtil.isLanguageLevel5OrHigher(field)) return;
-        final PsiType type = field.getType();
-        final Annotated annotated = check(field, holder, type);
-        if (TypeConversionUtil.isPrimitiveAndNotNull(type)) {
-          return;
-        }
-        Project project = holder.getProject();
-        final NullableNotNullManager manager = NullableNotNullManager.getInstance(project);
-        if (annotated.isDeclaredNotNull ^ annotated.isDeclaredNullable) {
-          final String anno = annotated.isDeclaredNotNull ? manager.getDefaultNotNull() : manager.getDefaultNullable();
-          final List<String> annoToRemove = annotated.isDeclaredNotNull ? manager.getNullables() : manager.getNotNulls();
-
-          if (!AnnotationUtil.isAnnotatingApplicable(field, anno)) {
-            final PsiAnnotation notNull = AnnotationUtil.findAnnotation(field, manager.getNotNulls());
-            final PsiAnnotation nullable = AnnotationUtil.findAnnotation(field, manager.getNullables());
-            holder.registerProblem(field.getNameIdentifier(), "Nullable/NotNull defaults are not accessible in current context",
-                                   new ChangeNullableDefaultsFix(notNull, nullable, manager));
-            return;
-          }
-
-          String propName = JavaCodeStyleManager.getInstance(project).variableNameToPropertyName(field.getName(), VariableKind.FIELD);
-          final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
-          final PsiMethod getter = PropertyUtil.findPropertyGetter(field.getContainingClass(), propName, isStatic, false);
-          final String nullableSimpleName = StringUtil.getShortName(manager.getDefaultNullable());
-          final String notNullSimpleName = StringUtil.getShortName(manager.getDefaultNotNull());
-          final PsiIdentifier nameIdentifier = getter == null ? null : getter.getNameIdentifier();
-          if (nameIdentifier != null && nameIdentifier.isPhysical()) {
-            if (PropertyUtils.isSimpleGetter(getter)) {
-              if (REPORT_NOT_ANNOTATED_GETTER) {
-                if (!AnnotationUtil.isAnnotated(getter, manager.getAllAnnotations(), false, false) &&
-                    !TypeConversionUtil.isPrimitiveAndNotNull(getter.getReturnType())) {
-                  holder.registerProblem(nameIdentifier, InspectionsBundle
-                    .message("inspection.nullable.problems.annotated.field.getter.not.annotated", StringUtil.getShortName(anno)),
-                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new AnnotateMethodFix(anno, ArrayUtil.toStringArray(annoToRemove)));
-                }
-              }
-              if (annotated.isDeclaredNotNull && manager.isNullable(getter, false)) {
-                holder.registerProblem(nameIdentifier, InspectionsBundle.message(
-                  "inspection.nullable.problems.annotated.field.getter.conflict", StringUtil.getShortName(anno), nullableSimpleName),
-                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new AnnotateMethodFix(anno, ArrayUtil.toStringArray(annoToRemove)));
-              } else if (annotated.isDeclaredNullable && manager.isNotNull(getter, false)) {
-                holder.registerProblem(nameIdentifier, InspectionsBundle.message(
-                  "inspection.nullable.problems.annotated.field.getter.conflict", StringUtil.getShortName(anno), notNullSimpleName),
-                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new AnnotateMethodFix(anno, ArrayUtil.toStringArray(annoToRemove)));
-              }
-            }
-          }
-
-          final PsiClass containingClass = field.getContainingClass();
-          final PsiMethod setter = PropertyUtil.findPropertySetter(containingClass, propName, isStatic, false);
-          if (setter != null) {
-            final PsiParameter[] parameters = setter.getParameterList().getParameters();
-            assert parameters.length == 1 : setter.getText();
-            final PsiParameter parameter = parameters[0];
-            LOG.assertTrue(parameter != null, setter.getText());
-            if (REPORT_NOT_ANNOTATED_GETTER && !AnnotationUtil.isAnnotated(parameter, manager.getAllAnnotations(), false, false) && !TypeConversionUtil.isPrimitiveAndNotNull(parameter.getType())) {
-              final PsiIdentifier nameIdentifier1 = parameter.getNameIdentifier();
-              assertValidElement(setter, parameter, nameIdentifier1);
-              holder.registerProblem(nameIdentifier1,
-                                     InspectionsBundle.message("inspection.nullable.problems.annotated.field.setter.parameter.not.annotated",
-                                                               StringUtil.getShortName(anno)),
-                                     ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                                     new AddAnnotationFix(anno, parameter, ArrayUtil.toStringArray(annoToRemove)));
-            }
-            if (PropertyUtils.isSimpleSetter(setter)) {
-              if (annotated.isDeclaredNotNull && manager.isNullable(parameter, false)) {
-                final PsiIdentifier nameIdentifier1 = parameter.getNameIdentifier();
-                assertValidElement(setter, parameter, nameIdentifier1);
-                holder.registerProblem(nameIdentifier1, InspectionsBundle.message(
-                                       "inspection.nullable.problems.annotated.field.setter.parameter.conflict",
-                                       StringUtil.getShortName(anno), nullableSimpleName),
-                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                                       new AddAnnotationFix(anno, parameter, ArrayUtil.toStringArray(annoToRemove)));
-              }
-              else if (annotated.isDeclaredNullable && manager.isNotNull(parameter, false)) {
-                final PsiIdentifier nameIdentifier1 = parameter.getNameIdentifier();
-                assertValidElement(setter, parameter, nameIdentifier1);
-                holder.registerProblem(nameIdentifier1, InspectionsBundle.message(
-                  "inspection.nullable.problems.annotated.field.setter.parameter.conflict", StringUtil.getShortName(anno), notNullSimpleName),
-                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                                       new AddAnnotationFix(anno, parameter, ArrayUtil.toStringArray(annoToRemove)));
-              }
-            }
-          }
-
-          for (PsiExpression rhs : findAllConstructorInitializers(field)) {
-            if (rhs instanceof PsiReferenceExpression) {
-              PsiElement target = ((PsiReferenceExpression)rhs).resolve();
-              if (target instanceof PsiParameter) {
-                PsiParameter parameter = (PsiParameter)target;
-                if (REPORT_NOT_ANNOTATED_GETTER && !AnnotationUtil.isAnnotated(parameter, manager.getAllAnnotations(), false, false) && !TypeConversionUtil.isPrimitiveAndNotNull(parameter.getType())) {
-                  final PsiIdentifier nameIdentifier2 = parameter.getNameIdentifier();
-                  assert nameIdentifier2 != null : parameter;
-                  holder.registerProblem(nameIdentifier2, InspectionsBundle
-                    .message("inspection.nullable.problems.annotated.field.constructor.parameter.not.annotated",
-                             StringUtil.getShortName(anno)),
-                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new AddAnnotationFix(anno, parameter, ArrayUtil.toStringArray(annoToRemove)));
-                  continue;
-                }
-                if (annotated.isDeclaredNotNull && manager.isNullable(parameter, false)) {
-                  final PsiIdentifier nameIdentifier2 = parameter.getNameIdentifier();
-                  assert nameIdentifier2 != null : parameter;
-                  holder.registerProblem(nameIdentifier2, InspectionsBundle.message(
-                    "inspection.nullable.problems.annotated.field.constructor.parameter.conflict", StringUtil.getShortName(anno),
-                    nullableSimpleName),
-                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                                         new AddAnnotationFix(anno, parameter, ArrayUtil.toStringArray(annoToRemove)));
-                }
-                else if (annotated.isDeclaredNullable && manager.isNotNull(parameter, false)) {
-                  boolean usedAsQualifier = !ReferencesSearch.search(parameter).forEach(new Processor<PsiReference>() {
-                    @Override
-                    public boolean process(PsiReference reference) {
-                      final PsiElement element = reference.getElement();
-                      if (element instanceof PsiReferenceExpression && element.getParent() instanceof PsiReferenceExpression) {
-                        return false;
-                      }
-                      return true;
-                    }
-                  });
-                  if (!usedAsQualifier) {
-                    final PsiIdentifier nameIdentifier2 = parameter.getNameIdentifier();
-                    assert nameIdentifier2 != null : parameter;
-                    holder.registerProblem(nameIdentifier2, InspectionsBundle.message(
-                      "inspection.nullable.problems.annotated.field.constructor.parameter.conflict", StringUtil.getShortName(anno),
-                      notNullSimpleName),
-                                           ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                                           new AddAnnotationFix(anno, parameter, ArrayUtil.toStringArray(annoToRemove)));
-                  }
-                }
-
-              }
-            }
-          }
-        }
-      }
-
-      private void assertValidElement(PsiMethod setter, PsiParameter parameter, PsiIdentifier nameIdentifier1) {
-        LOG.assertTrue(nameIdentifier1 != null && nameIdentifier1.isPhysical(), setter.getText());
-        LOG.assertTrue(parameter.isPhysical(), setter.getText());
-      }
-
-      @Override public void visitParameter(PsiParameter parameter) {
-        if (!PsiUtil.isLanguageLevel5OrHigher(parameter)) return;
-        check(parameter, holder, parameter.getType());
-      }
-    };
-  }
-
-  private static class Annotated {
-    private final boolean isDeclaredNotNull;
-    private final boolean isDeclaredNullable;
-
-    private Annotated(final boolean isDeclaredNotNull, final boolean isDeclaredNullable) {
-      this.isDeclaredNotNull = isDeclaredNotNull;
-      this.isDeclaredNullable = isDeclaredNullable;
-    }
-  }
-  private static Annotated check(final PsiModifierListOwner parameter, final ProblemsHolder holder, PsiType type) {
-    final NullableNotNullManager manager = NullableNotNullManager.getInstance(holder.getProject());
-    PsiAnnotation isDeclaredNotNull = AnnotationUtil.findAnnotation(parameter, manager.getNotNulls());
-    PsiAnnotation isDeclaredNullable = AnnotationUtil.findAnnotation(parameter, manager.getNullables());
-    if (isDeclaredNullable != null && isDeclaredNotNull != null) {
-      reportNullableNotNullConflict(holder, parameter, isDeclaredNullable,  isDeclaredNotNull);
-    }
-    if ((isDeclaredNotNull != null || isDeclaredNullable != null) && type != null && TypeConversionUtil.isPrimitive(type.getCanonicalText())) {
-      PsiAnnotation annotation = isDeclaredNotNull == null ? isDeclaredNullable : isDeclaredNotNull;
-      reportPrimitiveType(holder, annotation, annotation, parameter);
-    }
-    return new Annotated(isDeclaredNotNull != null,isDeclaredNullable != null);
-  }
-
-  private static void reportPrimitiveType(final ProblemsHolder holder, final PsiElement psiElement, final PsiAnnotation annotation,
-                                          final PsiModifierListOwner listOwner) {
-    holder.registerProblem(psiElement.isPhysical() ? psiElement : listOwner.getNavigationElement(),
-                           InspectionsBundle.message("inspection.nullable.problems.primitive.type.annotation"),
-                           ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new RemoveAnnotationQuickFix(annotation, listOwner));
-  }
-
-  @Override
-  @NotNull
-  public String getDisplayName() {
-    return InspectionsBundle.message("inspection.nullable.problems.display.name");
-  }
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.BUGS_GROUP_NAME;
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return "NullableProblems";
-  }
-
-  private void checkNullableStuffForMethod(PsiMethod method, final ProblemsHolder holder) {
-    Annotated annotated = check(method, holder, method.getReturnType());
-
-    PsiParameter[] parameters = method.getParameterList().getParameters();
-
-    List<MethodSignatureBackedByPsiMethod> superMethodSignatures = method.findSuperMethodSignaturesIncludingStatic(true);
-    boolean reported_not_annotated_method_overrides_notnull = false;
-    boolean reported_nullable_method_overrides_notnull = false;
-    boolean[] reported_notnull_parameter_overrides_nullable = new boolean[parameters.length];
-    boolean[] reported_not_annotated_parameter_overrides_notnull = new boolean[parameters.length];
-
-    final NullableNotNullManager nullableManager = NullableNotNullManager.getInstance(holder.getProject());
-    for (MethodSignatureBackedByPsiMethod superMethodSignature : superMethodSignatures) {
-      PsiMethod superMethod = superMethodSignature.getMethod();
-      if (!reported_nullable_method_overrides_notnull
-          && REPORT_NOTNULL_PARAMETER_OVERRIDES_NULLABLE
-          && annotated.isDeclaredNullable
-          && NullableNotNullManager.isNotNull(superMethod)) {
-        reported_nullable_method_overrides_notnull = true;
-        holder.registerProblem(method.getNameIdentifier(),
-                               InspectionsBundle.message("inspection.nullable.problems.Nullable.method.overrides.NotNull"),
-                               ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
-      }
-      if (!reported_not_annotated_method_overrides_notnull
-          && REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL
-          && !annotated.isDeclaredNullable
-          && !annotated.isDeclaredNotNull
-          && NullableNotNullManager.isNotNull(superMethod)) {
-        reported_not_annotated_method_overrides_notnull = true;
-        final String defaultNotNull = nullableManager.getDefaultNotNull();
-        final String[] annotationsToRemove = ArrayUtil.toStringArray(nullableManager.getNullables());
-        final LocalQuickFix fix = AnnotationUtil.isAnnotatingApplicable(method, defaultNotNull)
-                                  ? createAnnotateMethodFix(defaultNotNull, annotationsToRemove)
-                                  : createChangeDefaultNotNullFix(nullableManager, superMethod);
-        holder.registerProblem(method.getNameIdentifier(),
-                               InspectionsBundle.message("inspection.nullable.problems.method.overrides.NotNull"),
-                               ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                               wrapFix(fix));
-      }
-      if (REPORT_NOTNULL_PARAMETER_OVERRIDES_NULLABLE || REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL) {
-        PsiParameter[] superParameters = superMethod.getParameterList().getParameters();
-        if (superParameters.length != parameters.length) {
-          continue;
-        }
-        for (int i = 0; i < parameters.length; i++) {
-          PsiParameter parameter = parameters[i];
-          PsiParameter superParameter = superParameters[i];
-          if (!reported_notnull_parameter_overrides_nullable[i] && REPORT_NOTNULL_PARAMETER_OVERRIDES_NULLABLE &&
-              nullableManager.isNotNull(parameter, false) &&
-              nullableManager.isNullable(superParameter, false)) {
-            reported_notnull_parameter_overrides_nullable[i] = true;
-            holder.registerProblem(parameter.getNameIdentifier(),
-                                   InspectionsBundle.message("inspection.nullable.problems.NotNull.parameter.overrides.Nullable"),
-                                   ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
-          }
-          if (!reported_not_annotated_parameter_overrides_notnull[i] && REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL) {
-            if (!AnnotationUtil.isAnnotated(parameter, nullableManager.getAllAnnotations(), false, false) &&
-                nullableManager.isNotNull(superParameter, false)) {
-              reported_not_annotated_parameter_overrides_notnull[i] = true;
-              final LocalQuickFix fix = AnnotationUtil.isAnnotatingApplicable(parameter, nullableManager.getDefaultNotNull())
-                                        ? new AddNotNullAnnotationFix(parameter)
-                                        : createChangeDefaultNotNullFix(nullableManager, superParameter);
-              holder.registerProblem(parameter.getNameIdentifier(),
-                                     InspectionsBundle.message("inspection.nullable.problems.parameter.overrides.NotNull"),
-                                     ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                                     wrapFix(fix));
-            }
-          }
-        }
-      }
-    }
-
-    if (REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS) {
-      boolean[] parameterAnnotated = new boolean[parameters.length];
-      boolean[] parameterQuickFixSuggested = new boolean[parameters.length];
-      boolean hasAnnotatedParameter = false;
-      for (int i = 0; i < parameters.length; i++) {
-        PsiParameter parameter = parameters[i];
-        parameterAnnotated[i] = nullableManager.isNotNull(parameter, false);
-        hasAnnotatedParameter |= parameterAnnotated[i];
-      }
-      if (hasAnnotatedParameter || annotated.isDeclaredNotNull) {
-        PsiManager manager = method.getManager();
-        final String defaultNotNull = nullableManager.getDefaultNotNull();
-        final boolean superMethodApplicable = AnnotationUtil.isAnnotatingApplicable(method, defaultNotNull);
-        PsiMethod[] overridings =
-          OverridingMethodsSearch.search(method, GlobalSearchScope.allScope(manager.getProject()), true).toArray(PsiMethod.EMPTY_ARRAY);
-        boolean methodQuickFixSuggested = false;
-        for (PsiMethod overriding : overridings) {
-          if (!manager.isInProject(overriding)) continue;
-
-          final boolean applicable = AnnotationUtil.isAnnotatingApplicable(overriding, defaultNotNull);
-          if (!methodQuickFixSuggested
-              && annotated.isDeclaredNotNull
-              && !nullableManager.isNotNull(overriding, false)
-              && (nullableManager.isNullable(overriding, false) || !nullableManager.isNullable(overriding, true))) {
-            method.getNameIdentifier(); //load tree
-            PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, nullableManager.getNotNulls());
-            final String[] annotationsToRemove = ArrayUtil.toStringArray(nullableManager.getNullables());
-
-            final LocalQuickFix fix;
-            if (applicable) {
-              fix = new MyAnnotateMethodFix(defaultNotNull, annotationsToRemove);
-            }
-            else {
-              fix = superMethodApplicable ? null : createChangeDefaultNotNullFix(nullableManager, method);
-            }
-
-            PsiElement psiElement = annotation;
-            if (!annotation.isPhysical()) {
-              psiElement = method.getNameIdentifier();
-              if (psiElement == null) continue;
-            }
-            holder.registerProblem(psiElement, InspectionsBundle.message("nullable.stuff.problems.overridden.methods.are.not.annotated"),
-                                   ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                                   wrapFix(fix));
-            methodQuickFixSuggested = true;
-          }
-          if (hasAnnotatedParameter) {
-            PsiParameter[] psiParameters = overriding.getParameterList().getParameters();
-            for (int i = 0; i < psiParameters.length; i++) {
-              if (parameterQuickFixSuggested[i]) continue;
-              PsiParameter parameter = psiParameters[i];
-              if (parameterAnnotated[i] && !nullableManager.isNotNull(parameter, false) && !nullableManager.isNullable(parameter, false)) {
-                parameters[i].getNameIdentifier(); //be sure that corresponding tree element available
-                PsiAnnotation annotation = AnnotationUtil.findAnnotation(parameters[i], nullableManager.getNotNulls());
-                PsiElement psiElement = annotation;
-                if (!annotation.isPhysical()) {
-                  psiElement = parameters[i].getNameIdentifier();
-                  if (psiElement == null) continue;
-                }
-                holder.registerProblem(psiElement,
-                                       InspectionsBundle.message("nullable.stuff.problems.overridden.method.parameters.are.not.annotated"),
-                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                                       wrapFix(!applicable
-                                               ? createChangeDefaultNotNullFix(nullableManager, parameters[i])
-                                               : new AnnotateOverriddenMethodParameterFix(defaultNotNull,
-                                                                                          nullableManager.getDefaultNullable())));
-                parameterQuickFixSuggested[i] = true;
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-
-  private static LocalQuickFix[] wrapFix(LocalQuickFix fix) {
-    if (fix == null) return LocalQuickFix.EMPTY_ARRAY;
-    return new LocalQuickFix[]{fix};
-  }
-
-  private static LocalQuickFix createChangeDefaultNotNullFix(NullableNotNullManager nullableManager, PsiModifierListOwner modifierListOwner) {
-    final PsiAnnotation annotation = AnnotationUtil.findAnnotation(modifierListOwner, nullableManager.getNotNulls());
-    if (annotation != null) {
-      final PsiJavaCodeReferenceElement referenceElement = annotation.getNameReferenceElement();
-      if (referenceElement != null && referenceElement.resolve() != null) {
-        return new ChangeNullableDefaultsFix(annotation.getQualifiedName(), null, nullableManager);
-      }
-    }
-    return null;
-  }
-
-  protected AnnotateMethodFix createAnnotateMethodFix(final String defaultNotNull, final String[] annotationsToRemove) {
-    return new AnnotateMethodFix(defaultNotNull, annotationsToRemove);
-  }
-
-  private static void reportNullableNotNullConflict(final ProblemsHolder holder, final PsiModifierListOwner listOwner, final PsiAnnotation declaredNullable,
-                                                    final PsiAnnotation declaredNotNull) {
-    holder.registerProblem(declaredNotNull.isPhysical() ? declaredNotNull : listOwner.getNavigationElement(),
-                           InspectionsBundle.message("inspection.nullable.problems.Nullable.NotNull.conflict"),
-                           ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new RemoveAnnotationQuickFix(declaredNotNull, listOwner));
-    holder.registerProblem(declaredNullable.isPhysical() ? declaredNullable : listOwner.getNavigationElement(),
-                           InspectionsBundle.message("inspection.nullable.problems.Nullable.NotNull.conflict"),
-                           ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new RemoveAnnotationQuickFix(declaredNullable, listOwner));
-  }
-
+public class NullableStuffInspection extends NullableStuffInspectionBase {
   @Override
   public JComponent createOptionsPanel() {
     return new OptionsPanel();
   }
 
-  private static class MyAddNullableAnnotationFix extends AddNullableAnnotationFix {
-    public MyAddNullableAnnotationFix(PsiParameter parameter) {
-      super(parameter);
-    }
-
-    @Override
-    public boolean isAvailable(@NotNull Project project,
-                               @NotNull PsiFile file,
-                               @NotNull PsiElement startElement,
-                               @NotNull PsiElement endElement) {
-      return true;
-    }
-  }
-
-  private static class MyAnnotateMethodFix extends AnnotateMethodFix {
-    public MyAnnotateMethodFix(String defaultNotNull, String[] annotationsToRemove) {
-      super(defaultNotNull, annotationsToRemove);
-    }
-
-    @Override
-    protected boolean annotateOverriddenMethods() {
-      return true;
-    }
-
-    @Override
-    @NotNull
-    public String getName() {
-      return InspectionsBundle.message("annotate.overridden.methods.as.notnull", ClassUtil.extractClassName(myAnnotation));
-    }
-  }
-
   private class OptionsPanel extends JPanel {
     private JCheckBox myNNParameterOverridesN;
     private JCheckBox myNAMethodOverridesNN;
@@ -528,42 +77,4 @@
       REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL;
     }
   }
-
-  public static List<PsiExpression> findAllConstructorInitializers(PsiField field) {
-    final List<PsiExpression> result = ContainerUtil.createLockFreeCopyOnWriteList();
-    ContainerUtil.addIfNotNull(result, field.getInitializer());
-
-    PsiClass containingClass = field.getContainingClass();
-    if (containingClass != null) {
-      LocalSearchScope scope = new LocalSearchScope(containingClass.getConstructors());
-      ReferencesSearch.search(field, scope, false).forEach(new Processor<PsiReference>() {
-        @Override
-        public boolean process(PsiReference reference) {
-          final PsiElement element = reference.getElement();
-          if (element instanceof PsiReferenceExpression) {
-            final PsiAssignmentExpression assignment = getAssignmentExpressionIfOnAssignmentLhs(element);
-            final PsiMethod method = PsiTreeUtil.getParentOfType(assignment, PsiMethod.class);
-            if (method != null && method.isConstructor() && assignment != null) {
-              ContainerUtil.addIfNotNull(result, assignment.getRExpression());
-            }
-          }
-          return true;
-        }
-      });
-    }
-    return result;
-  }
-
-  @Nullable
-  private static PsiAssignmentExpression getAssignmentExpressionIfOnAssignmentLhs(PsiElement expression) {
-    PsiElement parent = PsiTreeUtil.skipParentsOfType(expression, PsiParenthesizedExpression.class);
-    if (!(parent instanceof PsiAssignmentExpression)) {
-      return null;
-    }
-    final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)parent;
-    if (!PsiTreeUtil.isAncestor(assignmentExpression.getLExpression(), expression, false)) {
-      return null;
-    }
-    return assignmentExpression;
-  }
 }
diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java
index a5e71fb..b8fea07 100644
--- a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java
+++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java
@@ -15,10 +15,7 @@
  */
 package com.intellij.codeInspection.reference;
 
-import com.intellij.codeInspection.InspectionProfileEntry;
-import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.SuppressManager;
-import com.intellij.codeInspection.SuppressionUtil;
+import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
 import com.intellij.codeInspection.ex.EntryPointsManager;
 import com.intellij.codeInspection.ex.EntryPointsManagerImpl;
@@ -450,7 +447,7 @@
     @Override
     public void visitAnnotation(PsiAnnotation annotation) {
       super.visitAnnotation(annotation);
-      if (Comparing.strEqual(annotation.getQualifiedName(), SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME)) {
+      if (Comparing.strEqual(annotation.getQualifiedName(), BatchSuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME)) {
         final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(annotation, PsiModifierListOwner.class);
         if (listOwner != null) {
           final RefElementImpl element = (RefElementImpl)myRefManager.getReference(listOwner);
diff --git a/java/java-impl/src/com/intellij/codeInspection/sillyAssignment/SillyAssignmentInspection.java b/java/java-impl/src/com/intellij/codeInspection/sillyAssignment/SillyAssignmentInspection.java
deleted file mode 100644
index bc9c679..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/sillyAssignment/SillyAssignmentInspection.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.sillyAssignment;
-
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * User: anna
- * Date: 15-Nov-2005
- */
-public class SillyAssignmentInspection extends BaseJavaLocalInspectionTool {
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return "";
-  }
-
-  @Override
-  @NotNull
-  public String getDisplayName() {
-    return InspectionsBundle.message("inspection.variable.assigned.to.itself.display.name");
-  }
-
-  @Override
-  @NotNull
-  @NonNls
-  public String getShortName() {
-    return "SillyAssignment";
-  }
-
-  @Override
-  public boolean isEnabledByDefault() {
-    return true;
-  }
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-
-      @Override public void visitAssignmentExpression(PsiAssignmentExpression expression) {
-        checkSillyAssignment(expression, holder);
-      }
-
-      @Override public void visitReferenceExpression(PsiReferenceExpression expression) {
-        visitElement(expression);
-      }
-
-      @Override public void visitVariable(final PsiVariable variable) {
-        final PsiExpression initializer = PsiUtil.deparenthesizeExpression(variable.getInitializer());
-        if (initializer instanceof PsiAssignmentExpression) {
-          final PsiExpression lExpr = PsiUtil.deparenthesizeExpression(((PsiAssignmentExpression)initializer).getLExpression());
-          checkExpression(variable, lExpr);
-        }
-        else {
-          checkExpression(variable, initializer);
-        }
-      }
-
-      private void checkExpression(PsiVariable variable, PsiExpression expression) {
-        if (!(expression instanceof PsiReferenceExpression)) {
-          return;
-        }
-        final PsiReferenceExpression refExpr = (PsiReferenceExpression)expression;
-        final PsiExpression qualifier = refExpr.getQualifierExpression();
-        if (qualifier == null || qualifier instanceof PsiThisExpression || qualifier instanceof PsiSuperExpression ||
-            variable.hasModifierProperty(PsiModifier.STATIC)) {
-          if (refExpr.isReferenceTo(variable)) {
-            holder.registerProblem(expression, InspectionsBundle.message("assignment.to.declared.variable.problem.descriptor",
-                                                                         variable.getName()), ProblemHighlightType.LIKE_UNUSED_SYMBOL);
-          }
-        }
-      }
-    };
-  }
-
-  private static void checkSillyAssignment(PsiAssignmentExpression assignment, ProblemsHolder holder) {
-    if (assignment.getOperationTokenType() != JavaTokenType.EQ) return;
-    PsiExpression lExpression = assignment.getLExpression();
-    PsiExpression rExpression = assignment.getRExpression();
-    if (rExpression == null) return;
-    lExpression = PsiUtil.deparenthesizeExpression(lExpression);
-    rExpression = PsiUtil.deparenthesizeExpression(rExpression);
-    if (!(lExpression instanceof PsiReferenceExpression)) return;
-    PsiReferenceExpression rRef;
-    if (!(rExpression instanceof PsiReferenceExpression)) {
-      if (!(rExpression instanceof PsiAssignmentExpression)) return;
-      final PsiAssignmentExpression rAssignmentExpression = (PsiAssignmentExpression)rExpression;
-      final PsiExpression assignee = PsiUtil.deparenthesizeExpression(rAssignmentExpression.getLExpression());
-      if (!(assignee instanceof PsiReferenceExpression)) return;
-      rRef = (PsiReferenceExpression)assignee;
-    } else {
-      rRef = (PsiReferenceExpression)rExpression;
-    }
-    PsiReferenceExpression lRef = (PsiReferenceExpression)lExpression;
-    PsiManager manager = assignment.getManager();
-    if (!sameInstanceReferences(lRef, rRef, manager)) return;
-    final PsiVariable variable = (PsiVariable)lRef.resolve();
-    if (variable == null) return;
-    holder.registerProblem(assignment, InspectionsBundle.message("assignment.to.itself.problem.descriptor", variable.getName()),
-                           ProblemHighlightType.LIKE_UNUSED_SYMBOL);
-  }
-
-  /**
-   * @return true if both expressions resolve to the same variable/class or field in the same instance of the class
-   */
-  private static boolean sameInstanceReferences(@Nullable PsiJavaCodeReferenceElement lRef, @Nullable PsiJavaCodeReferenceElement rRef, PsiManager manager) {
-    if (lRef == null && rRef == null) return true;
-    if (lRef == null || rRef == null) return false;
-    PsiElement lResolved = lRef.resolve();
-    PsiElement rResolved = rRef.resolve();
-    if (!manager.areElementsEquivalent(lResolved, rResolved)) return false;
-    if (!(lResolved instanceof PsiVariable)) return false;
-    final PsiVariable variable = (PsiVariable)lResolved;
-    if (variable.hasModifierProperty(PsiModifier.STATIC)) return true;
-
-    final PsiElement lQualifier = lRef.getQualifier();
-    final PsiElement rQualifier = rRef.getQualifier();
-    if (lQualifier instanceof PsiJavaCodeReferenceElement && rQualifier instanceof PsiJavaCodeReferenceElement) {
-      return sameInstanceReferences((PsiJavaCodeReferenceElement)lQualifier, (PsiJavaCodeReferenceElement)rQualifier, manager);
-    }
-
-    if (Comparing.equal(lQualifier, rQualifier)) return true;
-    boolean lThis = lQualifier == null || lQualifier instanceof PsiThisExpression || lQualifier instanceof PsiSuperExpression;
-    boolean rThis = rQualifier == null || rQualifier instanceof PsiThisExpression || rQualifier instanceof PsiSuperExpression;
-    if (lThis && rThis) {
-      final PsiJavaCodeReferenceElement llQualifier = getQualifier(lQualifier);
-      final PsiJavaCodeReferenceElement rrQualifier = getQualifier(rQualifier);
-      return sameInstanceReferences(llQualifier, rrQualifier, manager);
-    }
-    return false;
-  }
-
-  private static PsiJavaCodeReferenceElement getQualifier(PsiElement qualifier) {
-    if (qualifier instanceof PsiThisExpression) {
-      final PsiJavaCodeReferenceElement thisQualifier = ((PsiThisExpression)qualifier).getQualifier();
-      if (thisQualifier != null) {
-        final PsiClass innerMostClass = PsiTreeUtil.getParentOfType(thisQualifier, PsiClass.class);
-        if (innerMostClass == thisQualifier.resolve()) {
-          return null;
-        }
-      }
-      return thisQualifier;
-    } else if (qualifier != null) {
-      return  ((PsiSuperExpression)qualifier).getQualifier();
-    }
-    return null;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/testOnly/TestOnlyInspection.java b/java/java-impl/src/com/intellij/codeInspection/testOnly/TestOnlyInspection.java
deleted file mode 100644
index 20f1ea6..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/testOnly/TestOnlyInspection.java
+++ /dev/null
@@ -1,113 +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.testOnly;
-
-import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.codeInsight.TestFrameworks;
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class TestOnlyInspection extends BaseJavaLocalInspectionTool {
-  @Override
-  @NotNull
-  public String getDisplayName() {
-    return InspectionsBundle.message("inspection.test.only.problems.display.name");
-  }
-
-  @Override
-  @NotNull
-  public String getShortName() {
-    return "TestOnlyProblems";
-  }
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GENERAL_GROUP_NAME;
-  }
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder h, boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-      @Override public void visitCallExpression(PsiCallExpression e) {
-        validate(e, h);
-      }
-    };
-  }
-
-  private void validate(PsiCallExpression e, ProblemsHolder h) {
-    if (!isTestOnlyMethodCalled(e)) return;
-    if (isInsideTestOnlyMethod(e)) return;
-    if (isInsideTestClass(e)) return;
-    if (isUnderTestSources(e)) return;
-
-    reportProblem(e, h);
-  }
-
-  private boolean isTestOnlyMethodCalled(PsiCallExpression e) {
-    return isAnnotatedAsTestOnly(e.resolveMethod());
-  }
-
-  private boolean isInsideTestOnlyMethod(PsiCallExpression e) {
-    PsiMethod m = getTopLevelParentOfType(e, PsiMethod.class);
-    return isAnnotatedAsTestOnly(m);
-  }
-
-  private static boolean isAnnotatedAsTestOnly(@Nullable PsiMethod m) {
-    if (m == null) return false;
-    return AnnotationUtil.isAnnotated(m, AnnotationUtil.TEST_ONLY, false, false) ||
-           AnnotationUtil.isAnnotated(m, "com.google.common.annotations.VisibleForTesting", false, false);
-  }
-
-  private boolean isInsideTestClass(PsiCallExpression e) {
-    PsiClass c = getTopLevelParentOfType(e, PsiClass.class);
-    if (c == null) return false;
-    return TestFrameworks.getInstance().isTestClass(c);
-  }
-
-  private <T extends PsiElement> T getTopLevelParentOfType(PsiElement e, Class<T> c) {
-    T parent = PsiTreeUtil.getParentOfType(e, c);
-    if (parent == null) return null;
-
-    do {
-      T next = PsiTreeUtil.getParentOfType(parent, c);
-      if (next == null) return parent;
-      parent = next;
-    }
-    while (true);
-  }
-
-  private boolean isUnderTestSources(PsiCallExpression e) {
-    ProjectRootManager rm = ProjectRootManager.getInstance(e.getProject());
-    VirtualFile f = e.getContainingFile().getVirtualFile();
-    if (f == null) return false;
-    return rm.getFileIndex().isInTestSourceContent(f);
-  }
-
-  private void reportProblem(PsiCallExpression e, ProblemsHolder h) {
-    String message = InspectionsBundle.message("inspection.test.only.problems.test.only.method.call");
-    h.registerProblem(e, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java b/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java
index 2d363ec..24cc9d1 100644
--- a/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java
@@ -17,8 +17,8 @@
 package com.intellij.codeInspection.uncheckedWarnings;
 
 import com.intellij.codeInsight.daemon.JavaErrorMessages;
-import com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaGenericsUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.daemon.impl.quickfix.GenerifyFileFix;
 import com.intellij.codeInsight.daemon.impl.quickfix.VariableArrayTypeFix;
 import com.intellij.codeInsight.intention.IntentionAction;
@@ -177,7 +177,7 @@
     };
   }
 
-  public abstract class UncheckedWarningsVisitor extends JavaElementVisitor {
+  private abstract class UncheckedWarningsVisitor extends JavaElementVisitor {
     private final boolean myOnTheFly;
     private final LocalQuickFix[] myGenerifyFixes;
 
@@ -194,7 +194,7 @@
       if (IGNORE_UNCHECKED_GENERICS_ARRAY_CREATION) return;
       if (!PsiUtil.isLanguageLevel5OrHigher(expression)) return;
       final JavaResolveResult result = expression.advancedResolve(false);
-      if (GenericsHighlightUtil.isUncheckedWarning(expression, result)) {
+      if (JavaGenericsUtil.isUncheckedWarning(expression, result)) {
         registerProblem("Unchecked generics array creation for varargs parameter", expression, LocalQuickFix.EMPTY_ARRAY);
       }
     }
@@ -205,7 +205,7 @@
       if (IGNORE_UNCHECKED_GENERICS_ARRAY_CREATION) return;
       if (!PsiUtil.isLanguageLevel5OrHigher(expression)) return;
       final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference();
-      if (GenericsHighlightUtil.isUncheckedWarning(classReference, expression.resolveMethodGenerics())) {
+      if (JavaGenericsUtil.isUncheckedWarning(classReference, expression.resolveMethodGenerics())) {
         registerProblem("Unchecked generics array creation for varargs parameter", classReference, LocalQuickFix.EMPTY_ARRAY);
       }
     }
@@ -223,9 +223,10 @@
       final PsiType exprType = operand.getType();
       if (exprType == null) return;
       if (!TypeConversionUtil.areTypesConvertible(exprType, castType)) return;
-      if (GenericsHighlightUtil.isUncheckedCast(castType, exprType)) {
+      if (JavaGenericsUtil.isUncheckedCast(castType, exprType)) {
         final String description =
-          JavaErrorMessages.message("generics.unchecked.cast", HighlightUtil.formatType(exprType), HighlightUtil.formatType(castType));
+          JavaErrorMessages.message("generics.unchecked.cast", JavaHighlightUtil.formatType(exprType), JavaHighlightUtil
+            .formatType(castType));
         registerProblem(description, expression, myGenerifyFixes);
       }
     }
@@ -289,7 +290,7 @@
       final PsiType parameterType = parameter.getType();
       final PsiExpression iteratedValue = statement.getIteratedValue();
       if (iteratedValue == null) return;
-      final PsiType itemType = GenericsHighlightUtil.getCollectionItemType(iteratedValue);
+      final PsiType itemType = JavaGenericsUtil.getCollectionItemType(iteratedValue);
       if (!PsiUtil.isLanguageLevel5OrHigher(statement)) return;
       checkRawToGenericsAssignment(parameter, parameterType, itemType, true, myOnTheFly ? getChangeVariableTypeFixes(parameter, itemType) : LocalQuickFix.EMPTY_ARRAY);
     }
@@ -335,12 +336,12 @@
 
         if (itemType == null) continue;
         if (!TypeConversionUtil.isAssignable(componentType, itemType)) continue;
-        if (GenericsHighlightUtil.isRawToGeneric(componentType, itemType)) {
+        if (JavaGenericsUtil.isRawToGeneric(componentType, itemType)) {
           String description = JavaErrorMessages.message("generics.unchecked.assignment",
-                                                         HighlightUtil.formatType(itemType),
-                                                         HighlightUtil.formatType(componentType));
+                                                         JavaHighlightUtil.formatType(itemType),
+                                                         JavaHighlightUtil.formatType(componentType));
           if (!arrayTypeFixChecked) {
-            final PsiType checkResult = HighlightUtil.sameType(initializers);
+            final PsiType checkResult = JavaHighlightUtil.sameType(initializers);
             fix = checkResult != null ? new VariableArrayTypeFix(arrayInitializer, checkResult) : null;
             arrayTypeFixChecked = true;
           }
@@ -359,10 +360,10 @@
                                               @NotNull LocalQuickFix[] quickFixes) {
       if (parameterType == null || itemType == null) return;
       if (checkAssignability && !TypeConversionUtil.isAssignable(parameterType, itemType)) return;
-      if (GenericsHighlightUtil.isRawToGeneric(parameterType, itemType)) {
+      if (JavaGenericsUtil.isRawToGeneric(parameterType, itemType)) {
         String description = JavaErrorMessages.message("generics.unchecked.assignment",
-                                                       HighlightUtil.formatType(itemType),
-                                                       HighlightUtil.formatType(parameterType));
+                                                       JavaHighlightUtil.formatType(itemType),
+                                                       JavaHighlightUtil.formatType(parameterType));
         registerProblem(description, parameter, quickFixes);
       }
     }
@@ -384,10 +385,10 @@
             final PsiType baseReturnType = substitutor.substitute(baseMethod.getReturnType());
             final PsiType overriderReturnType = method.getReturnType();
             if (baseReturnType == null || overriderReturnType == null) return;
-            if (GenericsHighlightUtil.isRawToGeneric(baseReturnType, overriderReturnType)) {
+            if (JavaGenericsUtil.isRawToGeneric(baseReturnType, overriderReturnType)) {
               final String message = JavaErrorMessages.message("unchecked.overriding.incompatible.return.type",
-                                                               HighlightUtil.formatType(overriderReturnType),
-                                                               HighlightUtil.formatType(baseReturnType));
+                                                               JavaHighlightUtil.formatType(overriderReturnType),
+                                                               JavaHighlightUtil.formatType(baseReturnType));
 
               final PsiTypeElement returnTypeElement = method.getReturnTypeElement();
               LOG.assertTrue(returnTypeElement != null);
@@ -470,8 +471,8 @@
           final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
           PsiType type = elementFactory.createType(method.getContainingClass(), substitutor);
           return JavaErrorMessages.message("generics.unchecked.call.to.member.of.raw.type",
-                                                         HighlightUtil.formatMethod(method),
-                                                         HighlightUtil.formatType(type));
+                                                         JavaHighlightUtil.formatMethod(method),
+                                                         JavaHighlightUtil.formatType(type));
         }
       }
       return null;
diff --git a/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java b/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java
deleted file mode 100644
index 4c56961..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java
+++ /dev/null
@@ -1,127 +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.unneededThrows;
-
-import com.intellij.codeInsight.ExceptionUtil;
-import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInsight.daemon.JavaErrorMessages;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightMethodUtil;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
-import com.intellij.codeInspection.*;
-import com.intellij.psi.*;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author anna
- * @since 15-Nov-2005
- */
-public class RedundantThrowsDeclaration extends BaseJavaLocalInspectionTool {
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return GroupNames.DECLARATION_REDUNDANCY;
-  }
-
-  @Override
-  @NotNull
-  public String getDisplayName() {
-    return InspectionsBundle.message("redundant.throws.declaration");
-  }
-
-  @Override
-  @NotNull
-  @NonNls
-  public String getShortName() {
-    return "RedundantThrowsDeclaration";
-  }
-
-  @Override
-  @Nullable
-  public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
-    final Set<ProblemDescriptor> problems = new HashSet<ProblemDescriptor>();
-    file.accept(new JavaRecursiveElementWalkingVisitor() {
-      @Override public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
-        final ProblemDescriptor descriptor = checkExceptionsNeverThrown(reference, manager, isOnTheFly);
-        if (descriptor != null) {
-          problems.add(descriptor);
-        }
-      }
-
-    });
-    return problems.isEmpty() ? null : problems.toArray(new ProblemDescriptor[problems.size()]);
-  }
-
-  private static ProblemDescriptor checkExceptionsNeverThrown(PsiJavaCodeReferenceElement referenceElement,
-                                                              InspectionManager inspectionManager,
-                                                              boolean onTheFly) {
-    if (!(referenceElement.getParent() instanceof PsiReferenceList)) return null;
-    PsiReferenceList referenceList = (PsiReferenceList)referenceElement.getParent();
-    if (!(referenceList.getParent() instanceof PsiMethod)) return null;
-    PsiMethod method = (PsiMethod)referenceList.getParent();
-    if (referenceList != method.getThrowsList()) return null;
-    PsiClass containingClass = method.getContainingClass();
-    if (containingClass == null) return null;
-
-    PsiManager manager = referenceElement.getManager();
-    PsiClassType exceptionType = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(referenceElement);
-    if (ExceptionUtil.isUncheckedExceptionOrSuperclass(exceptionType)) return null;
-
-    PsiCodeBlock body = method.getBody();
-    if (body == null) return null;
-
-    PsiModifierList modifierList = method.getModifierList();
-    if (!modifierList.hasModifierProperty(PsiModifier.PRIVATE)
-        && !modifierList.hasModifierProperty(PsiModifier.STATIC)
-        && !modifierList.hasModifierProperty(PsiModifier.FINAL)
-        && !method.isConstructor()
-        && !(containingClass instanceof PsiAnonymousClass)
-        && !containingClass.hasModifierProperty(PsiModifier.FINAL)) {
-      return null;
-    }
-
-    Collection<PsiClassType> types = ExceptionUtil.collectUnhandledExceptions(body, method);
-    Collection<PsiClassType> unhandled = new HashSet<PsiClassType>(types);
-    if (method.isConstructor()) {
-      // there may be field initializer throwing exception
-      // that exception must be caught in the constructor
-      PsiField[] fields = containingClass.getFields();
-      for (final PsiField field : fields) {
-        if (field.hasModifierProperty(PsiModifier.STATIC)) continue;
-        PsiExpression initializer = field.getInitializer();
-        if (initializer == null) continue;
-        unhandled.addAll(ExceptionUtil.collectUnhandledExceptions(initializer, field));
-      }
-    }
-
-    for (PsiClassType unhandledException : unhandled) {
-      if (unhandledException.isAssignableFrom(exceptionType) || exceptionType.isAssignableFrom(unhandledException)) {
-        return null;
-      }
-    }
-
-    if (HighlightMethodUtil.isSerializationRelatedMethod(method, containingClass)) return null;
-
-    String description = JavaErrorMessages.message("exception.is.never.thrown", HighlightUtil.formatType(exceptionType));
-    LocalQuickFix quickFixes = new DeleteThrowsFix(method, exceptionType);
-    return inspectionManager.createProblemDescriptor(referenceElement, description, quickFixes, ProblemHighlightType.LIKE_UNUSED_SYMBOL, onTheFly);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/util/SpecialAnnotationsUtil.java b/java/java-impl/src/com/intellij/codeInspection/util/SpecialAnnotationsUtil.java
index 6e90687..1e630d4 100644
--- a/java/java-impl/src/com/intellij/codeInspection/util/SpecialAnnotationsUtil.java
+++ b/java/java-impl/src/com/intellij/codeInspection/util/SpecialAnnotationsUtil.java
@@ -16,12 +16,8 @@
 
 package com.intellij.codeInspection.util;
 
-import com.intellij.codeInsight.AnnotationUtil;
 import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.codeInspection.InspectionProfile;
 import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.ide.DataManager;
 import com.intellij.ide.util.ClassFilter;
 import com.intellij.ide.util.TreeClassChooser;
@@ -32,24 +28,18 @@
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectManager;
 import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.profile.codeInspection.InspectionProfileManager;
-import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.ui.*;
 import com.intellij.ui.components.JBList;
 import com.intellij.util.IconUtil;
 import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.Processor;
-import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
 import javax.swing.event.ListDataEvent;
 import javax.swing.event.ListDataListener;
 import java.awt.*;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 
@@ -169,7 +159,7 @@
 
       @Override
       public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
-        doQuickFixInternal(project, targetList, qualifiedName);
+        SpecialAnnotationsUtilBase.doQuickFixInternal(project, targetList, qualifiedName);
       }
 
       @Override
@@ -178,62 +168,4 @@
       }
     };
   }
-
-  public static LocalQuickFix createAddToSpecialAnnotationsListQuickFix(final String text,
-                                                                        final String family,
-                                                                        final List<String> targetList,
-                                                                        final String qualifiedName,
-                                                                        final PsiElement context) {
-    return new LocalQuickFix() {
-      @Override
-      @NotNull
-      public String getName() {
-        return text;
-      }
-
-      @Override
-      @NotNull
-      public String getFamilyName() {
-        return family;
-      }
-
-      @Override
-      public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
-        doQuickFixInternal(project, targetList, qualifiedName);
-      }
-    };
-  }
-
-  private static void doQuickFixInternal(final Project project, final List<String> targetList, final String qualifiedName) {
-    targetList.add(qualifiedName);
-    Collections.sort(targetList);
-    final InspectionProfile inspectionProfile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
-    //correct save settings
-
-    //TODO lesya
-    InspectionProfileManager.getInstance().fireProfileChanged(inspectionProfile);
-    /*
-    try {
-      inspectionProfile.save();
-    }
-    catch (IOException e) {
-      Messages.showErrorDialog(project, e.getMessage(), CommonBundle.getErrorTitle());
-    }
-
-    */
-  }
-
-  public static void createAddToSpecialAnnotationFixes(final PsiModifierListOwner owner, final Processor<String> processor) {
-    final PsiModifierList modifierList = owner.getModifierList();
-    if (modifierList != null) {
-      final PsiAnnotation[] psiAnnotations = modifierList.getAnnotations();
-      for (PsiAnnotation psiAnnotation : psiAnnotations) {
-        @NonNls final String name = psiAnnotation.getQualifiedName();
-        if (name == null) continue;
-        if (name.startsWith("java.") || name.startsWith("javax.") ||
-            (name.startsWith("org.jetbrains.") && AnnotationUtil.isJetbrainsAnnotation(StringUtil.getShortName(name)))) continue;
-        if (!processor.process(name)) break;
-      }
-    }
-  }
 }
diff --git a/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/BaseConvertToLocalQuickFix.java b/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/BaseConvertToLocalQuickFix.java
index bbe84bd..6dd3558 100644
--- a/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/BaseConvertToLocalQuickFix.java
+++ b/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/BaseConvertToLocalQuickFix.java
@@ -41,7 +41,7 @@
 import java.util.Set;
 
 /**
- * refactored from {@link com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection.MyQuickFix}
+ * refactored from {@link com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection}
  *
  * @author Danila Ponomarenko
  */
@@ -57,8 +57,8 @@
   @Override
   public final void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
     final V variable = getVariable(descriptor);
-    final PsiFile myFile = variable.getContainingFile();
     if (variable == null || !variable.isValid()) return; //weird. should not get here when field becomes invalid
+    final PsiFile myFile = variable.getContainingFile();
 
     try {
       final PsiElement newDeclaration = moveDeclaration(project, variable);
@@ -142,12 +142,12 @@
     );
   }
 
-  protected PsiElement applyChanges(final @NotNull Project project,
-                                    final @NotNull String localName,
-                                    final @Nullable PsiExpression initializer,
-                                    final @NotNull V variable,
-                                    final @NotNull Collection<PsiReference> references,
-                                    final @NotNull NotNullFunction<PsiDeclarationStatement, PsiElement> action) {
+  protected PsiElement applyChanges(@NotNull final Project project,
+                                    @NotNull final String localName,
+                                    @Nullable final PsiExpression initializer,
+                                    @NotNull final V variable,
+                                    @NotNull final Collection<PsiReference> references,
+                                    @NotNull final NotNullFunction<PsiDeclarationStatement, PsiElement> action) {
     final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
 
     return ApplicationManager.getApplication().runWriteAction(
@@ -202,11 +202,7 @@
 
     final PsiReferenceExpression leftExpression = (PsiReferenceExpression)expression.getLExpression();
 
-    if (!leftExpression.isReferenceTo(variable)) {
-      return false;
-    }
-
-    return true;
+    return leftExpression.isReferenceTo(variable);
   }
 
   @NotNull
@@ -273,9 +269,4 @@
     }
     return result;
   }
-
-
-  public boolean runForWholeFile() {
-    return true;
-  }
 }
diff --git a/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/AdjustPackageNameFix.java b/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/AdjustPackageNameFix.java
deleted file mode 100644
index d5f88fe..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/AdjustPackageNameFix.java
+++ /dev/null
@@ -1,83 +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.wrongPackageStatement;
-
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-
-public class AdjustPackageNameFix implements LocalQuickFix {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.wrongPackageStatement.AdjustPackageNameFix");
-  private final String myName;
-
-  public AdjustPackageNameFix(String targetPackage) {
-    myName = targetPackage;
-  }
-
-  @Override
-  @NotNull
-  public String getName() {
-    return QuickFixBundle.message("adjust.package.text", myName);
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return QuickFixBundle.message("adjust.package.family");
-  }
-
-  @Override
-  public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
-    PsiElement element = descriptor.getPsiElement();
-    if (element == null) return;
-    PsiFile myFile = element.getContainingFile();
-    if (!FileModificationService.getInstance().prepareFileForWrite(myFile)) return;
-
-    PsiDirectory directory = myFile.getContainingDirectory();
-    if (directory == null) return;
-    PsiPackage myTargetPackage = JavaDirectoryService.getInstance().getPackage(directory);
-    if (myTargetPackage == null) return;
-
-    try {
-      PsiElementFactory factory = JavaPsiFacade.getInstance(myFile.getProject()).getElementFactory();
-      PsiPackageStatement myStatement = ((PsiJavaFile)myFile).getPackageStatement();
-
-      if (myTargetPackage.getQualifiedName().length() == 0) {
-        if (myStatement != null) {
-          myStatement.delete();
-        }
-      }
-      else {
-        final PsiPackageStatement packageStatement = factory.createPackageStatement(myTargetPackage.getQualifiedName());
-        if (myStatement != null) {
-          myStatement.getPackageReference().replace(packageStatement.getPackageReference());
-        }
-        else {
-          myFile.addAfter(packageStatement, null);
-        }
-      }
-    }
-    catch (IncorrectOperationException e) {
-      LOG.error(e);
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java b/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java
index e6fc026..3f4bd05 100644
--- a/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java
@@ -15,105 +15,22 @@
  */
 package com.intellij.codeInspection.wrongPackageStatement;
 
-import com.intellij.codeHighlighting.HighlightDisplayLevel;
-import com.intellij.codeInsight.daemon.JavaErrorMessages;
-import com.intellij.codeInspection.*;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.psi.*;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import com.intellij.codeInspection.LocalQuickFix;
+import com.intellij.codeInspection.MoveToPackageFix;
+import com.intellij.psi.PsiFile;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
  * User: anna
  * Date: 14-Nov-2005
  */
-public class WrongPackageStatementInspection extends BaseJavaLocalInspectionTool {
+public class WrongPackageStatementInspection extends WrongPackageStatementInspectionBase {
   @Override
-  @Nullable
-  public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
-    // does not work in tests since CodeInsightTestCase copies file into temporary location
-    if (ApplicationManager.getApplication().isUnitTestMode()) return null;
-    if (file instanceof PsiJavaFile) {
-      if (JspPsiUtil.isInJspFile(file)) return null;
-      PsiJavaFile javaFile = (PsiJavaFile)file;
-
-      PsiDirectory directory = javaFile.getContainingDirectory();
-      if (directory == null) return null;
-      PsiPackage dirPackage = JavaDirectoryService.getInstance().getPackage(directory);
-      if (dirPackage == null) return null;
-      PsiPackageStatement packageStatement = javaFile.getPackageStatement();
-
-      // highlight the first class in the file only
-      PsiClass[] classes = javaFile.getClasses();
-      if (classes.length == 0 && packageStatement == null) return null;
-
-      String packageName = dirPackage.getQualifiedName();
-      if (!Comparing.strEqual(packageName, "", true) && packageStatement == null) {
-        String description = JavaErrorMessages.message("missing.package.statement", packageName);
-
-        return new ProblemDescriptor[]{manager.createProblemDescriptor(classes[0].getNameIdentifier(), description,
-                                                                       new AdjustPackageNameFix(packageName),
-                                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly)};
-      }
-      if (packageStatement != null) {
-        final PsiJavaCodeReferenceElement packageReference = packageStatement.getPackageReference();
-        PsiPackage classPackage = (PsiPackage)packageReference.resolve();
-        List<LocalQuickFix> availableFixes = new ArrayList<LocalQuickFix>();
-        if (classPackage == null || !Comparing.equal(dirPackage.getQualifiedName(), packageReference.getQualifiedName(), true)) {
-          availableFixes.add(new AdjustPackageNameFix(packageName));
-          MoveToPackageFix moveToPackageFix = new MoveToPackageFix(classPackage != null ? classPackage.getQualifiedName() : packageReference.getQualifiedName());
-          if (moveToPackageFix.isAvailable(file)) {
-            availableFixes.add(moveToPackageFix);
-          }
-        }
-        if (!availableFixes.isEmpty()){
-          String description = JavaErrorMessages.message("package.name.file.path.mismatch",
-                                                         packageReference.getQualifiedName(),
-                                                         dirPackage.getQualifiedName());
-          LocalQuickFix[] fixes = availableFixes.toArray(new LocalQuickFix[availableFixes.size()]);
-          ProblemDescriptor descriptor =
-            manager.createProblemDescriptor(packageStatement.getPackageReference(), description, isOnTheFly,
-                                            fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
-          return new ProblemDescriptor[]{descriptor};
-
-        }
-      }
+  protected void addMoveToPackageFix(PsiFile file, String packName, List<LocalQuickFix> availableFixes) {
+    MoveToPackageFix moveToPackageFix = new MoveToPackageFix(packName);
+    if (moveToPackageFix.isAvailable(file)) {
+      availableFixes.add(moveToPackageFix);
     }
-    return null;
-  }
-
-  @Override
-  @NotNull
-  public String getGroupDisplayName() {
-    return "";
-  }
-
-  @Override
-  @NotNull
-  public HighlightDisplayLevel getDefaultLevel() {
-    return HighlightDisplayLevel.ERROR;
-  }
-
-  @Override
-  @NotNull
-  public String getDisplayName() {
-    return InspectionsBundle.message("wrong.package.statement");
-  }
-
-  @Override
-  @NotNull
-  @NonNls
-  public String getShortName() {
-    return "WrongPackageStatement";
-  }
-
-  @Override
-  public boolean isEnabledByDefault() {
-    return true;
   }
 }
diff --git a/java/java-impl/src/com/intellij/externalSystem/JavaProjectData.java b/java/java-impl/src/com/intellij/externalSystem/JavaProjectData.java
new file mode 100644
index 0000000..29f991c
--- /dev/null
+++ b/java/java-impl/src/com/intellij/externalSystem/JavaProjectData.java
@@ -0,0 +1,163 @@
+/*
+ * 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.externalSystem;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.externalSystem.model.Key;
+import com.intellij.openapi.externalSystem.model.ProjectSystemId;
+import com.intellij.openapi.externalSystem.model.project.AbstractExternalEntityData;
+import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
+import com.intellij.openapi.projectRoots.JavaSdkVersion;
+import com.intellij.pom.java.LanguageLevel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Denis Zhdanov
+ * @since 4/12/13 12:27 PM
+ */
+public class JavaProjectData extends AbstractExternalEntityData {
+  
+  @NotNull public static final Key<JavaProjectData> KEY = Key.create(JavaProjectData.class);
+  
+  private static final Logger LOG = Logger.getInstance("#" + JavaProjectData.class.getName());
+
+  private static final long serialVersionUID = 1L;
+
+  private static final LanguageLevel  DEFAULT_LANGUAGE_LEVEL = LanguageLevel.JDK_1_6;
+  private static final JavaSdkVersion DEFAULT_JDK_VERSION    = JavaSdkVersion.JDK_1_6;
+  private static final Pattern        JDK_VERSION_PATTERN    = Pattern.compile(".*1\\.(\\d+).*");
+
+  @NotNull private JavaSdkVersion myJdkVersion    = DEFAULT_JDK_VERSION;
+  @NotNull private LanguageLevel  myLanguageLevel = DEFAULT_LANGUAGE_LEVEL;
+
+  @NotNull private  String myCompileOutputPath;
+
+  public JavaProjectData(@NotNull ProjectSystemId owner, @NotNull String compileOutputPath) {
+    super(owner);
+    myCompileOutputPath = compileOutputPath;
+  }
+
+  @NotNull
+  public String getCompileOutputPath() {
+    return myCompileOutputPath;
+  }
+
+  public void setCompileOutputPath(@NotNull String compileOutputPath) {
+    myCompileOutputPath = ExternalSystemApiUtil.toCanonicalPath(compileOutputPath);
+  }
+
+  @NotNull
+  public JavaSdkVersion getJdkVersion() {
+    return myJdkVersion;
+  }
+
+  public void setJdkVersion(@NotNull JavaSdkVersion jdkVersion) {
+    myJdkVersion = jdkVersion;
+  }
+
+  public void setJdkVersion(@Nullable String jdk) {
+    if (jdk == null) {
+      return;
+    }
+    try {
+      int version = Integer.parseInt(jdk.trim());
+      if (applyJdkVersion(version)) {
+        return;
+      }
+    }
+    catch (NumberFormatException e) {
+      // Ignore.
+    }
+
+    Matcher matcher = JDK_VERSION_PATTERN.matcher(jdk);
+    if (!matcher.matches()) {
+      return;
+    }
+    String versionAsString = matcher.group(1);
+    try {
+      applyJdkVersion(Integer.parseInt(versionAsString));
+    }
+    catch (NumberFormatException e) {
+      // Ignore.
+    }
+  }
+
+  public boolean applyJdkVersion(int version) {
+    if (version < 0 || version >= JavaSdkVersion.values().length) {
+      LOG.warn(String.format(
+        "Unsupported jdk version detected (%d). Expected to get number from range [0; %d]", version, JavaSdkVersion.values().length
+      ));
+      return false;
+    }
+    for (JavaSdkVersion sdkVersion : JavaSdkVersion.values()) {
+      if (sdkVersion.ordinal() == version) {
+        myJdkVersion = sdkVersion;
+        return true;
+      }
+    }
+    assert false : version + ", max value: " + JavaSdkVersion.values().length;
+    return false;
+  }
+
+  @NotNull
+  public LanguageLevel getLanguageLevel() {
+    return myLanguageLevel;
+  }
+
+  public void setLanguageLevel(@NotNull LanguageLevel level) {
+    myLanguageLevel = level;
+  }
+
+  public void setLanguageLevel(@Nullable String languageLevel) {
+    LanguageLevel level = LanguageLevel.parse(languageLevel);
+    if (level != null) {
+      myLanguageLevel = level;
+    }
+  }
+
+  @Override
+  public int hashCode() {
+    int result = super.hashCode();
+    result = 31 * result + myJdkVersion.hashCode();
+    result = 31 * result + myLanguageLevel.hashCode();
+    result = 31 * result + myCompileOutputPath.hashCode();
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+    if (!super.equals(o)) return false;
+
+    JavaProjectData project = (JavaProjectData)o;
+
+    if (!myCompileOutputPath.equals(project.myCompileOutputPath)) return false;
+    if (myJdkVersion != project.myJdkVersion) return false;
+    if (myLanguageLevel != project.myLanguageLevel) return false;
+
+    return true;
+  }
+
+  @Override
+  public String toString() {
+    return "java project";
+  }
+}
diff --git a/java/java-impl/src/com/intellij/externalSystem/JavaProjectDataService.java b/java/java-impl/src/com/intellij/externalSystem/JavaProjectDataService.java
new file mode 100644
index 0000000..47f4b0a
--- /dev/null
+++ b/java/java-impl/src/com/intellij/externalSystem/JavaProjectDataService.java
@@ -0,0 +1,116 @@
+/*
+ * 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.externalSystem;
+
+import com.intellij.openapi.externalSystem.model.DataNode;
+import com.intellij.openapi.externalSystem.model.Key;
+import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataService;
+import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.projectRoots.JavaSdk;
+import com.intellij.openapi.projectRoots.JavaSdkVersion;
+import com.intellij.openapi.projectRoots.ProjectJdkTable;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.roots.LanguageLevelProjectExtension;
+import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.pom.java.LanguageLevel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author Denis Zhdanov
+ * @since 4/15/13 12:09 PM
+ */
+public class JavaProjectDataService implements ProjectDataService<JavaProjectData, Project> {
+
+  @NotNull
+  @Override
+  public Key<JavaProjectData> getTargetDataKey() {
+    return JavaProjectData.KEY;
+  }
+
+  @Override
+  public void importData(@NotNull Collection<DataNode<JavaProjectData>> toImport, @NotNull Project project, boolean synchronous) {
+    if (!ExternalSystemApiUtil.isNewProjectConstruction()) {
+      return;
+    }
+    if (toImport.size() != 1) {
+      throw new IllegalArgumentException(String.format("Expected to get a single project but got %d: %s", toImport.size(), toImport));
+    }
+    JavaProjectData projectData = toImport.iterator().next().getData();
+
+    // JDK.
+    JavaSdkVersion version = projectData.getJdkVersion();
+    JavaSdk javaSdk = JavaSdk.getInstance();
+    ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
+    Sdk sdk = rootManager.getProjectSdk();
+    if (sdk instanceof JavaSdk) {
+      JavaSdkVersion currentVersion = javaSdk.getVersion(sdk);
+      if (currentVersion == null || !currentVersion.isAtLeast(version)) {
+        Sdk newJdk = findJdk(version);
+        if (newJdk != null) {
+          rootManager.setProjectSdk(sdk);
+          LanguageLevel level = version.getMaxLanguageLevel();
+          LanguageLevelProjectExtension ext = LanguageLevelProjectExtension.getInstance(project);
+          if (level.compareTo(ext.getLanguageLevel()) < 0) {
+            ext.setLanguageLevel(level);
+          }
+        }
+      }
+    }
+    // Language level.
+    setLanguageLevel(projectData.getLanguageLevel(), project, synchronous);
+  }
+
+  @Nullable
+  private static Sdk findJdk(@NotNull JavaSdkVersion version) {
+    JavaSdk javaSdk = JavaSdk.getInstance();
+    List<Sdk> javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk);
+    Sdk candidate = null;
+    for (Sdk sdk : javaSdks) {
+      JavaSdkVersion v = javaSdk.getVersion(sdk);
+      if (v == version) {
+        return sdk;
+      }
+      else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) {
+        candidate = sdk;
+      }
+    }
+    return candidate;
+  }
+
+  @Override
+  public void removeData(@NotNull Collection<? extends Project> toRemove, @NotNull Project project, boolean synchronous) {
+  }
+
+  @SuppressWarnings("MethodMayBeStatic")
+  public void setLanguageLevel(@NotNull final LanguageLevel languageLevel, @NotNull Project project, boolean synchronous) {
+    final LanguageLevelProjectExtension languageLevelExtension = LanguageLevelProjectExtension.getInstance(project);
+    if (languageLevelExtension.getLanguageLevel().isAtLeast(languageLevel)) {
+      return;
+    }
+    ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+      @Override
+      public void run() {
+        languageLevelExtension.setLanguageLevel(languageLevel);
+      }
+    });
+  }
+  
+}
diff --git a/java/java-impl/src/com/intellij/ide/actions/JavaQualifiedNameProvider.java b/java/java-impl/src/com/intellij/ide/actions/JavaQualifiedNameProvider.java
index 4f49420..de3446e 100644
--- a/java/java-impl/src/com/intellij/ide/actions/JavaQualifiedNameProvider.java
+++ b/java/java-impl/src/com/intellij/ide/actions/JavaQualifiedNameProvider.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.ide.actions;
 
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
@@ -220,7 +220,7 @@
         catch (IncorrectOperationException e) {
           // failed to bind
         }
-        if (referenceExpression.isValid() && !isReferencedTo(referenceExpression, targetElement)) {
+        if (!referenceExpression.isValid() || !isReferencedTo(referenceExpression, targetElement)) {
           toInsert = fqn;
         }
       }
@@ -241,7 +241,7 @@
         LOG.error(e);
       }
     }
-    CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(file);
+    CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(file);
     try {
       CodeStyleManager.getInstance(project).adjustLineIndent(file, offset);
     }
diff --git a/java/java-impl/src/com/intellij/ide/highlighter/JavaFileHighlighter.java b/java/java-impl/src/com/intellij/ide/highlighter/JavaFileHighlighter.java
index cec7c4a..c4d1369 100644
--- a/java/java-impl/src/com/intellij/ide/highlighter/JavaFileHighlighter.java
+++ b/java/java-impl/src/com/intellij/ide/highlighter/JavaFileHighlighter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
 import com.intellij.lexer.JavaHighlightingLexer;
 import com.intellij.lexer.Lexer;
 import com.intellij.openapi.editor.HighlighterColors;
-import com.intellij.openapi.editor.SyntaxHighlighterColors;
 import com.intellij.openapi.editor.colors.TextAttributesKey;
 import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
 import com.intellij.pom.java.LanguageLevel;
@@ -39,21 +38,11 @@
   private static final Map<IElementType, TextAttributesKey> ourMap1;
   private static final Map<IElementType, TextAttributesKey> ourMap2;
 
-  private final LanguageLevel myLanguageLevel;
-
-  public JavaFileHighlighter() {
-    this(LanguageLevel.HIGHEST);
-  }
-
-  public JavaFileHighlighter(LanguageLevel languageLevel) {
-    myLanguageLevel = languageLevel;
-  }
-
   static {
     ourMap1 = new HashMap<IElementType, TextAttributesKey>();
     ourMap2 = new HashMap<IElementType, TextAttributesKey>();
 
-    fillMap(ourMap1, ElementType.KEYWORD_BIT_SET, JavaHighlightingColors .KEYWORD);
+    fillMap(ourMap1, ElementType.KEYWORD_BIT_SET, JavaHighlightingColors.KEYWORD);
     fillMap(ourMap1, ElementType.LITERAL_BIT_SET, JavaHighlightingColors.KEYWORD);
     fillMap(ourMap1, ElementType.OPERATION_BIT_SET, JavaHighlightingColors.OPERATION_SIGN);
 
@@ -96,25 +85,28 @@
     ourMap1.put(JavaDocTokenType.DOC_TAG_NAME, JavaHighlightingColors.DOC_COMMENT);
     ourMap2.put(JavaDocTokenType.DOC_TAG_NAME, JavaHighlightingColors.DOC_COMMENT_TAG);
 
-    IElementType[] javaDocMarkup = new IElementType[]{XmlTokenType.XML_START_TAG_START,
-                                        XmlTokenType.XML_END_TAG_START,
-                                        XmlTokenType.XML_TAG_END,
-                                        XmlTokenType.XML_EMPTY_ELEMENT_END,
-                                        XmlTokenType.TAG_WHITE_SPACE,
-                                        XmlTokenType.XML_TAG_NAME,
-                                        XmlTokenType.XML_NAME,
-                                        XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN,
-                                        XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER,
-                                        XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER,
-                                        XmlTokenType.XML_CHAR_ENTITY_REF,
-                                        XmlTokenType.XML_EQ};
-
+    IElementType[] javaDocMarkup = {
+      XmlTokenType.XML_START_TAG_START, XmlTokenType.XML_END_TAG_START, XmlTokenType.XML_TAG_END, XmlTokenType.XML_EMPTY_ELEMENT_END,
+      XmlTokenType.TAG_WHITE_SPACE, XmlTokenType.XML_TAG_NAME, XmlTokenType.XML_NAME, XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN,
+      XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER, XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER, XmlTokenType.XML_CHAR_ENTITY_REF,
+      XmlTokenType.XML_EQ
+    };
     for (IElementType idx : javaDocMarkup) {
       ourMap1.put(idx, JavaHighlightingColors.DOC_COMMENT);
       ourMap2.put(idx, JavaHighlightingColors.DOC_COMMENT_MARKUP);
     }
   }
 
+  private final LanguageLevel myLanguageLevel;
+
+  public JavaFileHighlighter() {
+    this(LanguageLevel.HIGHEST);
+  }
+
+  public JavaFileHighlighter(@NotNull LanguageLevel languageLevel) {
+    myLanguageLevel = languageLevel;
+  }
+
   @NotNull
   public Lexer getHighlightingLexer() {
     return new JavaHighlightingLexer(myLanguageLevel);
diff --git a/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java b/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java
index 2aae5d8..e8197bb 100644
--- a/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java
+++ b/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,10 +21,12 @@
 import com.intellij.ide.projectView.impl.nodes.ClassTreeNode;
 import com.intellij.ide.projectView.impl.nodes.PsiFileNode;
 import com.intellij.ide.util.treeView.AbstractTreeNode;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
 import com.intellij.psi.jsp.JspFile;
@@ -67,7 +69,12 @@
         }
 
         if (fileInRoots(file)) {
-          PsiClass[] classes = classOwner.getClasses();
+          PsiClass[] classes = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass[]>() {
+            @Override
+            public PsiClass[] compute() {
+              return classOwner.getClasses();
+            }
+          });
           if (classes.length == 1 && !(classes[0] instanceof SyntheticElement) &&
               (file == null || file.getNameWithoutExtension().equals(classes[0].getName()))) {
             result.add(new ClassTreeNode(myProject, classes[0], settings1));
diff --git a/java/java-impl/src/com/intellij/ide/util/PackageChooserDialog.java b/java/java-impl/src/com/intellij/ide/util/PackageChooserDialog.java
index 245f342..2ad3edc 100644
--- a/java/java-impl/src/com/intellij/ide/util/PackageChooserDialog.java
+++ b/java/java-impl/src/com/intellij/ide/util/PackageChooserDialog.java
@@ -22,6 +22,11 @@
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.command.CommandProcessor;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.event.*;
+import com.intellij.openapi.editor.event.DocumentAdapter;
+import com.intellij.openapi.fileChooser.ex.FileChooserDialogImpl;
+import com.intellij.openapi.fileChooser.ex.TextFieldAction;
+import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.ContentIterator;
@@ -35,9 +40,10 @@
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
-import com.intellij.ui.ScrollPaneFactory;
-import com.intellij.ui.TreeSpeedSearch;
+import com.intellij.ui.*;
+import com.intellij.ui.components.labels.LinkLabel;
 import com.intellij.ui.treeStructure.Tree;
+import com.intellij.util.Alarm;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.PlatformIcons;
 import com.intellij.util.containers.Convertor;
@@ -66,6 +72,9 @@
   private final Project myProject;
   private final String myTitle;
   private Module myModule;
+  private EditorTextField myPathEditor;
+
+  private Alarm myAlarm = new Alarm(getDisposable()); 
 
   public PackageChooserDialog(String title, @NotNull Module module) {
     super(module.getProject(), true);
@@ -147,19 +156,69 @@
         else {
           setTitle(myTitle);
         }
+        updatePathFromTree();
       }
     });
 
     panel.add(scrollPane, BorderLayout.CENTER);
     DefaultActionGroup group = createActionGroup(myTree);
 
+    final JPanel northPanel = new JPanel(new BorderLayout());
+    panel.add(northPanel, BorderLayout.NORTH);
     ActionToolbar toolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
-    panel.add(toolBar.getComponent(), BorderLayout.NORTH);
-    toolBar.getComponent().setAlignmentX(JComponent.LEFT_ALIGNMENT);
-
+    northPanel.add(toolBar.getComponent(), BorderLayout.WEST);
+    setupPathComponent(northPanel);
     return panel;
   }
 
+  private void setupPathComponent(final JPanel northPanel) {
+    northPanel.add(new TextFieldAction() {
+      @Override
+      public void linkSelected(LinkLabel aSource, Object aLinkData) {
+        toggleShowPathComponent(northPanel, this);
+      }
+    }, BorderLayout.EAST);
+    myPathEditor = new EditorTextField(JavaReferenceEditorUtil.createDocument("", myProject, false), myProject, StdFileTypes.JAVA);
+    myPathEditor.addDocumentListener(new DocumentAdapter() {
+      @Override
+      public void documentChanged(DocumentEvent e) {
+        myAlarm.cancelAllRequests();
+        myAlarm.addRequest(new Runnable() {
+          @Override
+          public void run() {
+            updateTreeFromPath();
+          }
+        }, 300);
+      }
+    });
+    myPathEditor.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));
+    northPanel.add(myPathEditor, BorderLayout.SOUTH);
+  }
+
+  private void toggleShowPathComponent(JPanel northPanel, TextFieldAction fieldAction) {
+    boolean toShowTextField = !isPathShowing();
+    PropertiesComponent.getInstance().setValue(FileChooserDialogImpl.FILE_CHOOSER_SHOW_PATH_PROPERTY, Boolean.toString(toShowTextField));
+    myPathEditor.setVisible(toShowTextField);
+    fieldAction.update();
+    northPanel.revalidate();
+    northPanel.repaint();
+    updatePathFromTree();
+  }
+
+  private static boolean isPathShowing() {
+    return PropertiesComponent.getInstance().getBoolean(FileChooserDialogImpl.FILE_CHOOSER_SHOW_PATH_PROPERTY, true);
+  }
+
+  private void updatePathFromTree() {
+    if (!isPathShowing()) return;
+    final PsiPackage selection = getTreeSelection();
+    myPathEditor.setText(selection != null ? selection.getQualifiedName() : "");
+  }
+
+  private void updateTreeFromPath() {
+    selectPackage(myPathEditor.getText().trim());
+  }
+  
   private DefaultActionGroup createActionGroup(JComponent component) {
     final DefaultActionGroup group = new DefaultActionGroup();
     final DefaultActionGroup temp = new DefaultActionGroup();
diff --git a/java/java-impl/src/com/intellij/ide/util/SuperMethodWarningDialog.java b/java/java-impl/src/com/intellij/ide/util/SuperMethodWarningDialog.java
index 15c17f6..eb09ceb 100644
--- a/java/java-impl/src/com/intellij/ide/util/SuperMethodWarningDialog.java
+++ b/java/java-impl/src/com/intellij/ide/util/SuperMethodWarningDialog.java
@@ -80,12 +80,19 @@
                                  ? IdeBundle.message("label.overrides.method.of_class_or_interface.name", methodString, classType, className)
                                  : IdeBundle.message("label.implements.method.of_class_or_interface.name", methodString, classType, className)));
     } else {
-      labelsPanel.add(new JLabel(IdeBundle.message("label.implements.method.of_interfaces")));
+      final JLabel multLabel = new JLabel(IdeBundle.message("label.implements.method.of_interfaces"));
+      multLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
+      labelsPanel.add(multLabel);
+ 
       for (final String className : myClassNames) {
         labelsPanel.add(new JLabel("    " + className));
       }
     }
-    labelsPanel.add(new JLabel(IdeBundle.message("prompt.do.you.want.to.action_verb.the.method.from_class", myActionString, myClassNames.length > 1 ? 2 : 1)));
+ 
+    final JLabel doYouWantLabel = new JLabel(
+      IdeBundle.message("prompt.do.you.want.to.action_verb.the.method.from_class", myActionString, myClassNames.length > 1 ? 2 : 1));
+    doYouWantLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
+    labelsPanel.add(doYouWantLabel);
     panel.add(labelsPanel, BorderLayout.CENTER);
     return panel;
   }
diff --git a/java/java-impl/src/com/intellij/ide/util/SuperMethodWarningUtil.java b/java/java-impl/src/com/intellij/ide/util/SuperMethodWarningUtil.java
index 5ac29a8..efb05d7 100644
--- a/java/java-impl/src/com/intellij/ide/util/SuperMethodWarningUtil.java
+++ b/java/java-impl/src/com/intellij/ide/util/SuperMethodWarningUtil.java
@@ -15,9 +15,12 @@
  */
 package com.intellij.ide.util;
 
+import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiElement;
@@ -27,7 +30,6 @@
 import com.intellij.psi.search.PsiElementProcessor;
 import com.intellij.psi.search.searches.DeepestSuperMethodsSearch;
 import com.intellij.ui.components.JBList;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.ArrayUtil;
 import org.jetbrains.annotations.NotNull;
 
@@ -68,7 +70,7 @@
     }
 
     SuperMethodWarningDialog dialog =
-        new SuperMethodWarningDialog(method.getProject(), UsageViewUtil.getDescriptiveName(method), actionString, superAbstract,
+        new SuperMethodWarningDialog(method.getProject(), DescriptiveNameUtil.getDescriptiveName(method), actionString, superAbstract,
                                      parentInterface, aClass.isInterface(), ArrayUtil.toStringArray(superClasses));
     dialog.show();
 
@@ -97,7 +99,7 @@
     SuperMethodWarningDialog dialog =
         new SuperMethodWarningDialog(
             method.getProject(),
-            UsageViewUtil.getDescriptiveName(method), actionString, containingClass.isInterface() || superMethod.hasModifierProperty(PsiModifier.ABSTRACT),
+            DescriptiveNameUtil.getDescriptiveName(method), actionString, containingClass.isInterface() || superMethod.hasModifierProperty(PsiModifier.ABSTRACT),
             containingClass.isInterface(), aClass.isInterface(), containingClass.getQualifiedName()
         );
     dialog.show();
@@ -154,4 +156,16 @@
         }
       }).createPopup().showInBestPositionFor(editor);
   }
+
+  public static int askWhetherShouldAnnotateBaseMethod(@NotNull PsiMethod method, @NotNull PsiMethod superMethod) {
+    String implement = !method.hasModifierProperty(PsiModifier.ABSTRACT) && superMethod.hasModifierProperty(PsiModifier.ABSTRACT)
+                  ? InspectionsBundle.message("inspection.annotate.quickfix.implements")
+                  : InspectionsBundle.message("inspection.annotate.quickfix.overrides");
+    String message = InspectionsBundle.message("inspection.annotate.quickfix.overridden.method.messages",
+                                               DescriptiveNameUtil.getDescriptiveName(method), implement,
+                                               DescriptiveNameUtil.getDescriptiveName(superMethod));
+    String title = InspectionsBundle.message("inspection.annotate.quickfix.overridden.method.warning");
+    return Messages.showYesNoCancelDialog(method.getProject(), message, title, Messages.getQuestionIcon());
+
+  }
 }
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/ide/util/scopeChooser/ClassHierarchyScopeDescriptor.java b/java/java-impl/src/com/intellij/ide/util/scopeChooser/ClassHierarchyScopeDescriptor.java
index 075e091..99826b8 100644
--- a/java/java-impl/src/com/intellij/ide/util/scopeChooser/ClassHierarchyScopeDescriptor.java
+++ b/java/java-impl/src/com/intellij/ide/util/scopeChooser/ClassHierarchyScopeDescriptor.java
@@ -30,7 +30,7 @@
 import com.intellij.psi.search.LocalSearchScope;
 import com.intellij.psi.search.SearchScope;
 import com.intellij.psi.search.searches.ClassInheritorsSearch;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.PsiUtilCore;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.LinkedList;
@@ -64,7 +64,7 @@
 
       classesToSearch.addAll(ClassInheritorsSearch.search(aClass, true).findAll());
 
-      myCachedScope = new LocalSearchScope(PsiUtilBase.toPsiElementArray(classesToSearch),
+      myCachedScope = new LocalSearchScope(PsiUtilCore.toPsiElementArray(classesToSearch),
                                            IdeBundle.message("scope.hierarchy", ClassPresentationUtil.getNameForClass(aClass, true)));
     }
 
diff --git a/java/java-impl/src/com/intellij/lang/java/JavaSyntaxHighlighterFactory.java b/java/java-impl/src/com/intellij/lang/java/JavaSyntaxHighlighterFactory.java
index 87d9e78..918b8ff 100644
--- a/java/java-impl/src/com/intellij/lang/java/JavaSyntaxHighlighterFactory.java
+++ b/java/java-impl/src/com/intellij/lang/java/JavaSyntaxHighlighterFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,44 @@
 package com.intellij.lang.java;
 
 import com.intellij.ide.highlighter.JavaFileHighlighter;
+import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.fileTypes.SyntaxHighlighter;
 import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
+import com.intellij.openapi.fileTypes.SyntaxHighlighterProvider;
 import com.intellij.openapi.module.LanguageLevelUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.pom.java.LanguageLevel;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiManager;
+import com.intellij.psi.impl.compiled.ClsFileImpl;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
-public class JavaSyntaxHighlighterFactory extends SyntaxHighlighterFactory {
+public class JavaSyntaxHighlighterFactory extends SyntaxHighlighterFactory implements SyntaxHighlighterProvider {
+  /**
+   * SyntaxHighlighterFactory implementation (for Java source files).
+   */
   @Override
   @NotNull
-  public SyntaxHighlighter getSyntaxHighlighter(final Project project, final VirtualFile virtualFile) {
-    return new JavaFileHighlighter(
-      virtualFile != null ? LanguageLevelUtil.getLanguageLevelForFile(virtualFile) : LanguageLevel.HIGHEST);
+  public SyntaxHighlighter getSyntaxHighlighter(@Nullable Project project, @Nullable VirtualFile file) {
+    return new JavaFileHighlighter(LanguageLevelUtil.getLanguageLevelForFile(file));
+  }
+
+  /**
+   * SyntaxHighlighterProvider implementation (for class files).
+   */
+  @Nullable
+  @Override
+  public SyntaxHighlighter create(FileType fileType, @Nullable Project project, @Nullable VirtualFile file) {
+    if (project != null && file != null) {
+      PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
+      if (psiFile instanceof ClsFileImpl) {
+        LanguageLevel sourceLevel = ((ClsFileImpl)psiFile).getSourceLanguageLevel();
+        return new JavaFileHighlighter(sourceLevel);
+      }
+    }
+
+    return new JavaFileHighlighter();
   }
 }
diff --git a/java/java-impl/src/com/intellij/profile/codeInspection/JavaAwareInspectionProfileManager.java b/java/java-impl/src/com/intellij/profile/codeInspection/JavaAwareInspectionProfileManager.java
index 5404d0a..e1d50a7 100644
--- a/java/java-impl/src/com/intellij/profile/codeInspection/JavaAwareInspectionProfileManager.java
+++ b/java/java-impl/src/com/intellij/profile/codeInspection/JavaAwareInspectionProfileManager.java
@@ -25,7 +25,7 @@
 import com.intellij.codeInspection.ex.InspectionToolRegistrar;
 import com.intellij.openapi.options.SchemesManagerFactory;
 
-public class JavaAwareInspectionProfileManager extends InspectionProfileManager{
+public class JavaAwareInspectionProfileManager extends InspectionProfileManagerImpl {
   public JavaAwareInspectionProfileManager(InspectionToolRegistrar registrar, SchemesManagerFactory schemesManagerFactory) {
     super(registrar, schemesManagerFactory);
   }
diff --git a/java/java-impl/src/com/intellij/psi/AbstractQualifiedReference.java b/java/java-impl/src/com/intellij/psi/AbstractQualifiedReference.java
index 5853791..d26892e 100644
--- a/java/java-impl/src/com/intellij/psi/AbstractQualifiedReference.java
+++ b/java/java-impl/src/com/intellij/psi/AbstractQualifiedReference.java
@@ -40,7 +40,8 @@
 /**
  * @author peter
  */
-public abstract class AbstractQualifiedReference<T extends AbstractQualifiedReference<T>> extends ASTWrapperPsiElement implements PsiPolyVariantReference, PsiQualifiedReference {
+public abstract class AbstractQualifiedReference<T extends AbstractQualifiedReference<T>> extends ASTWrapperPsiElement
+  implements PsiPolyVariantReference, PsiQualifiedReferenceElement {
   private static final ResolveCache.PolyVariantResolver<AbstractQualifiedReference> MY_RESOLVER = new ResolveCache.PolyVariantResolver<AbstractQualifiedReference>() {
     @NotNull
     @Override
diff --git a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java
index 89c7d47..001745c 100644
--- a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java
+++ b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java
@@ -292,7 +292,7 @@
     and(matchRules, CLASS, STATIC);
     and(matchRules, CLASS);
 
-    return new StdArrangementSettings(groupingRules, matchRules);
+    return new StdRulePriorityAwareSettings(groupingRules, matchRules);
   }
 
   @Nullable
diff --git a/java/java-impl/src/com/intellij/psi/controlFlow/DefUseUtil.java b/java/java-impl/src/com/intellij/psi/controlFlow/DefUseUtil.java
deleted file mode 100644
index 658164e..0000000
--- a/java/java-impl/src/com/intellij/psi/controlFlow/DefUseUtil.java
+++ /dev/null
@@ -1,486 +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.psi.controlFlow;
-
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.PsiUtilBase;
-import com.intellij.util.containers.IntArrayList;
-import com.intellij.util.containers.Queue;
-import gnu.trove.THashSet;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author max
- * Date: Mar 22, 2002
- */
-public class DefUseUtil {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.defUse.DefUseUtil");
-
-  private DefUseUtil() { }
-
-  public static class Info {
-    private final PsiVariable myVariable;
-    private final PsiElement myContext;
-    private final boolean myIsRead;
-
-    public Info(PsiVariable variable, PsiElement context, boolean read) {
-      myVariable = variable;
-      myContext = context;
-      myIsRead = read;
-    }
-
-    public PsiVariable getVariable() {
-      return myVariable;
-    }
-
-    public PsiElement getContext() {
-      return myContext;
-    }
-
-    public boolean isRead() {
-      return myIsRead;
-    }
-  }
-
-  private static class InstructionState {
-    private Set<PsiVariable> myVariablesUseArmed;
-    private final int myInstructionIdx;
-    private final IntArrayList myBackwardTraces;
-    private boolean myIsVisited = false;
-
-    public InstructionState(int instructionIdx) {
-      myInstructionIdx = instructionIdx;
-      myBackwardTraces = new IntArrayList();
-      myVariablesUseArmed = null;
-    }
-
-    public void addBackwardTrace(int i) {
-      myBackwardTraces.add(i);
-    }
-
-    public IntArrayList getBackwardTraces() {
-      return myBackwardTraces;
-    }
-
-    public int getInstructionIdx() {
-      return myInstructionIdx;
-    }
-
-    void mergeUseArmed(PsiVariable psiVariable) {
-      touch();
-      myVariablesUseArmed.add(psiVariable);
-    }
-
-    boolean mergeUseDisarmed(PsiVariable psiVariable) {
-      touch();
-
-      boolean result = myVariablesUseArmed.contains(psiVariable);
-      myVariablesUseArmed.remove(psiVariable);
-
-      return result;
-    }
-
-    private void touch() {
-      if (myVariablesUseArmed == null) myVariablesUseArmed = new THashSet<PsiVariable>();
-    }
-
-    public void merge(InstructionState state) {
-      touch();
-      myVariablesUseArmed.addAll(state.myVariablesUseArmed);
-    }
-
-    public boolean contains(InstructionState state) {
-      return myVariablesUseArmed != null && state.myVariablesUseArmed != null &&
-             myVariablesUseArmed.containsAll(state.myVariablesUseArmed);
-    }
-
-    public boolean markVisited() {
-      boolean old = myIsVisited;
-      myIsVisited = true;
-      return old;
-    }
-
-    public boolean isVisited() {
-      return myIsVisited;
-    }
-  }
-
-  @Nullable
-  public static List<Info> getUnusedDefs(PsiCodeBlock body, Set<PsiVariable> outUsedVariables) {
-    if (body == null) {
-      return null;
-    }
-
-    ControlFlow flow;
-    try {
-      flow = ControlFlowFactory.getInstance(body.getProject()).getControlFlow(body, ourPolicy);
-    }
-    catch (AnalysisCanceledException e) {
-      return null;
-    }
-    List<Instruction> instructions = flow.getInstructions();
-    if (LOG.isDebugEnabled()) {
-      LOG.debug(flow.toString());
-    }
-
-    Set<PsiVariable> assignedVariables = new THashSet<PsiVariable>();
-    Set<PsiVariable> readVariables = new THashSet<PsiVariable>();
-    for (int i = 0; i < instructions.size(); i++) {
-      Instruction instruction = instructions.get(i);
-      ProgressManager.checkCanceled();
-      if (instruction instanceof WriteVariableInstruction) {
-        WriteVariableInstruction writeInstruction = (WriteVariableInstruction)instruction;
-        PsiElement context = flow.getElement(i);
-        context = PsiTreeUtil.getParentOfType(context, PsiStatement.class, false);
-        PsiVariable psiVariable = writeInstruction.variable;
-        if (context != null && !(context instanceof PsiDeclarationStatement && psiVariable.getInitializer() == null)) {
-          assignedVariables.add(psiVariable);
-        }
-      }
-      else if (instruction instanceof ReadVariableInstruction) {
-        ReadVariableInstruction readInstruction = (ReadVariableInstruction)instruction;
-        readVariables.add(readInstruction.variable);
-      }
-    }
-
-    InstructionState[] states = getStates(instructions);
-
-    boolean[] defsArmed = new boolean[instructions.size()];
-
-    Queue<InstructionState> queue = new Queue<InstructionState>(8);
-
-    for (int i = states.length - 1; i >= 0; i--) {
-      final InstructionState outerState = states[i];
-      if (outerState.isVisited()) continue;
-      outerState.touch();
-
-      for (PsiVariable psiVariable : assignedVariables) {
-        if (psiVariable instanceof PsiField) {
-          outerState.mergeUseArmed(psiVariable);
-        }
-      }
-      queue.addLast(outerState);
-
-      while (!queue.isEmpty()) {
-        ProgressManager.checkCanceled();
-        InstructionState state = queue.pullFirst();
-        state.markVisited();
-
-        int idx = state.getInstructionIdx();
-        if (idx < instructions.size()) {
-          Instruction instruction = instructions.get(idx);
-
-          if (instruction instanceof WriteVariableInstruction) {
-            WriteVariableInstruction writeInstruction = (WriteVariableInstruction)instruction;
-            PsiVariable psiVariable = writeInstruction.variable;
-            outUsedVariables.add(psiVariable);
-            if (state.mergeUseDisarmed(psiVariable)) {
-              defsArmed[idx] = true;
-            }
-          }
-          else if (instruction instanceof ReadVariableInstruction) {
-            ReadVariableInstruction readInstruction = (ReadVariableInstruction)instruction;
-            state.mergeUseArmed(readInstruction.variable);
-            outUsedVariables.add(readInstruction.variable);
-          }
-          else {
-            state.touch();
-          }
-        }
-
-        IntArrayList backwardTraces = state.getBackwardTraces();
-        for (int j = 0; j < backwardTraces.size(); j++) {
-          int prevIdx = backwardTraces.get(j);
-          InstructionState prevState = states[prevIdx];
-          if (!prevState.contains(state)) {
-            prevState.merge(state);
-            queue.addLast(prevState);
-          }
-        }
-      }
-    }
-
-    List<Info> unusedDefs = new ArrayList<Info>();
-
-    for (int i = 0; i < instructions.size(); i++) {
-      Instruction instruction = instructions.get(i);
-      if (instruction instanceof WriteVariableInstruction) {
-        WriteVariableInstruction writeInstruction = (WriteVariableInstruction)instruction;
-        if (!defsArmed[i]) {
-          PsiElement context = PsiTreeUtil.getNonStrictParentOfType(flow.getElement(i),
-                                                                    PsiStatement.class, PsiAssignmentExpression.class,
-                                                                    PsiPostfixExpression.class, PsiPrefixExpression.class);
-          PsiVariable psiVariable = writeInstruction.variable;
-          if (context != null && !(context instanceof PsiTryStatement)) {
-            if (context instanceof PsiDeclarationStatement && psiVariable.getInitializer() == null) {
-              if (!assignedVariables.contains(psiVariable)) {
-                unusedDefs.add(new Info(psiVariable, context, false));
-              }
-            }
-            else {
-              unusedDefs.add(new Info(psiVariable, context, readVariables.contains(psiVariable)));
-            }
-          }
-        }
-      }
-    }
-
-    return unusedDefs;
-  }
-
-  @NotNull
-  public static PsiElement[] getDefs(PsiCodeBlock body, final PsiVariable def, PsiElement ref) {
-    try {
-      RefsDefs refsDefs = new RefsDefs(body) {
-        private final InstructionState[] states = getStates(instructions);
-
-        @Override
-        protected int nNext(int index) {
-          return states[index].getBackwardTraces().size();
-        }
-
-        @Override
-        protected int getNext(int index, int no) {
-          return states[index].getBackwardTraces().get(no);
-        }
-
-        @Override
-        protected boolean defs() {
-          return true;
-        }
-
-        @Override
-        protected void processInstruction(final Set<PsiElement> res, final Instruction instruction, int index) {
-          if (instruction instanceof WriteVariableInstruction) {
-            WriteVariableInstruction instructionW = (WriteVariableInstruction)instruction;
-            if (instructionW.variable == def) {
-
-              final PsiElement element = flow.getElement(index);
-              element.accept(new JavaRecursiveElementWalkingVisitor() {
-                @Override
-                public void visitReferenceExpression(PsiReferenceExpression ref) {
-                  if (PsiUtil.isAccessedForWriting(ref)) {
-                    if (ref.resolve() == def) {
-                      res.add(ref);
-                    }
-                  }
-                }
-
-                @Override
-                public void visitVariable(PsiVariable var) {
-                  if (var == def && (var instanceof PsiParameter || var.hasInitializer())) {
-                    res.add(var);
-                  }
-                }
-              });
-            }
-          }
-        }
-      };
-      return refsDefs.get(def, ref);
-    }
-    catch (AnalysisCanceledException e) {
-      return PsiElement.EMPTY_ARRAY;
-    }
-  }
-
-  @NotNull
-  public static PsiElement[] getRefs(PsiCodeBlock body, final PsiVariable def, PsiElement ref) {
-    try {
-      RefsDefs refsDefs = new RefsDefs(body) {
-        @Override
-        protected int nNext(int index) {
-          return instructions.get(index).nNext();
-        }
-
-        @Override
-        protected int getNext(int index, int no) {
-          return instructions.get(index).getNext(index, no);
-        }
-
-        @Override
-        protected boolean defs() {
-          return false;
-        }
-
-        @Override
-        protected void processInstruction(final Set<PsiElement> res, final Instruction instruction, int index) {
-          if (instruction instanceof ReadVariableInstruction) {
-            ReadVariableInstruction instructionR = (ReadVariableInstruction)instruction;
-            if (instructionR.variable == def) {
-
-              final PsiElement element = flow.getElement(index);
-              element.accept(new JavaRecursiveElementWalkingVisitor() {
-                @Override
-                public void visitReferenceExpression(PsiReferenceExpression ref) {
-                  if (ref.resolve() == def) {
-                    res.add(ref);
-                  }
-                }
-              });
-            }
-          }
-        }
-      };
-      return refsDefs.get(def, ref);
-    }
-    catch (AnalysisCanceledException e) {
-      return PsiElement.EMPTY_ARRAY;
-    }
-  }
-
-  private abstract static class RefsDefs {
-    protected abstract int   nNext(int index);
-    protected abstract int getNext(int index, int no);
-
-    final List<Instruction> instructions;
-    final ControlFlow flow;
-    final PsiCodeBlock body;
-
-
-    protected RefsDefs(PsiCodeBlock body) throws AnalysisCanceledException {
-      this.body = body;
-      flow = ControlFlowFactory.getInstance(body.getProject()).getControlFlow(body, ourPolicy);
-      instructions = flow.getInstructions();
-    }
-
-    protected abstract void processInstruction(Set<PsiElement> res, final Instruction instruction, int index);
-    protected abstract boolean defs ();
-
-    @NotNull
-    private PsiElement[] get (final PsiVariable def, PsiElement refOrDef) {
-      if (body == null) {
-        return PsiElement.EMPTY_ARRAY;
-      }
-
-      final boolean [] visited = new boolean[instructions.size() + 1];
-      visited [visited.length-1] = true; // stop on the code end
-      int elem = defs() ? flow.getStartOffset(refOrDef) : flow.getEndOffset(refOrDef);
-
-      // hack: ControlFlow doesn't contains parameters initialization
-      if (elem == -1 && def instanceof PsiParameter) {
-        elem = 0;
-      }
-
-      if (elem != -1) {
-        if (!defs () && instructions.get(elem) instanceof ReadVariableInstruction) {
-          LOG.assertTrue(nNext(elem) == 1);
-          LOG.assertTrue(getNext(elem,0) == elem+1);
-          elem += 1;
-        }
-
-        final Set<PsiElement> res = new THashSet<PsiElement>();
-        class Inner {
-
-          void traverse (int index) {
-            visited [index] = true;
-
-            if (defs ()) {
-              final Instruction instruction = instructions.get(index);
-              processInstruction(res, instruction, index);
-              if (instruction instanceof WriteVariableInstruction) {
-                WriteVariableInstruction instructionW = (WriteVariableInstruction)instruction;
-                if (instructionW.variable == def) {
-                  return;
-                }
-              }
-
-              // hack: ControlFlow doesnn't contains parameters initialization
-              if (index == 0 && def instanceof PsiParameter) {
-                res.add(def.getNameIdentifier());
-              }
-            }
-
-            final int nNext = nNext (index);
-            for (int i = 0; i < nNext; i++) {
-              final int prev = getNext(index, i);
-              if (!visited [prev]) {
-                if (!defs ()) {
-                  final Instruction instruction = instructions.get(prev);
-                  if (instruction instanceof WriteVariableInstruction) {
-                    WriteVariableInstruction instructionW = (WriteVariableInstruction)instruction;
-                    if (instructionW.variable == def) {
-                      continue;
-                    }
-                  } else {
-                    processInstruction(res, instruction, prev);
-                  }
-                }
-                traverse (prev);
-
-              }
-            }
-          }
-        }
-        new Inner ().traverse (elem);
-        return PsiUtilBase.toPsiElementArray(res);
-      }
-      return PsiElement.EMPTY_ARRAY;
-    }
-  }
-
-
-  private static InstructionState[] getStates(final List<Instruction> instructions) {
-    final InstructionState[] states = new InstructionState[instructions.size()];
-    for (int i = 0; i < states.length; i++) {
-      states[i] = new InstructionState(i);
-    }
-
-    for (int i = 0; i < instructions.size(); i++) {
-      final Instruction instruction = instructions.get(i);
-      for (int j = 0; j != instruction.nNext(); ++ j) {
-        final int next = instruction.getNext(i, j);
-        if (next < states.length) {
-          states[next].addBackwardTrace(i);
-        }
-      }
-    }
-    return states;
-  }
-
-  private static final ControlFlowPolicy ourPolicy = new ControlFlowPolicy() {
-    @Override
-    public PsiVariable getUsedVariable(PsiReferenceExpression refExpr) {
-      if (refExpr.isQualified()) return null;
-
-      PsiElement refElement = refExpr.resolve();
-      if (refElement instanceof PsiLocalVariable || refElement instanceof PsiParameter) {
-        return (PsiVariable) refElement;
-      }
-
-      return null;
-    }
-
-    @Override
-    public boolean isParameterAccepted(PsiParameter psiParameter) {
-      return true;
-    }
-
-    @Override
-    public boolean isLocalVariableAccepted(PsiLocalVariable psiVariable) {
-      return true;
-    }
-  };
-}
diff --git a/java/java-impl/src/com/intellij/psi/controlFlow/LocalsControlFlowPolicy.java b/java/java-impl/src/com/intellij/psi/controlFlow/LocalsControlFlowPolicy.java
deleted file mode 100644
index 333ed4c..0000000
--- a/java/java-impl/src/com/intellij/psi/controlFlow/LocalsControlFlowPolicy.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.psi.controlFlow;
-
-import com.intellij.psi.*;
-import org.jetbrains.annotations.Nullable;
-
-public class LocalsControlFlowPolicy implements ControlFlowPolicy {
-  private final PsiElement myCodeFragment;
-
-  public LocalsControlFlowPolicy(PsiElement codeFragment) {
-    myCodeFragment = codeFragment;
-  }
-
-  @Override
-  public PsiVariable getUsedVariable(PsiReferenceExpression refExpr) {
-    if (refExpr.isQualified()) return null;
-
-    PsiElement refElement = refExpr.resolve();
-    return refElement instanceof PsiLocalVariable || refElement instanceof PsiParameter ? checkCodeFragment(refElement) : null;
-  }
-
-  @Nullable
-  private PsiVariable checkCodeFragment(PsiElement refElement) {
-    PsiElement codeFragment = ControlFlowUtil.findCodeFragment(refElement);
-    if (refElement instanceof PsiParameter) {
-      final PsiElement declarationScope = ((PsiParameter)refElement).getDeclarationScope();
-      if (declarationScope instanceof PsiMethod) {
-        codeFragment = ((PsiMethod)declarationScope).getBody();
-      }
-      else if (declarationScope instanceof PsiLambdaExpression) {
-        codeFragment = ((PsiLambdaExpression)declarationScope).getBody();
-      }
-    }
-    if (codeFragment == null) return null;
-    if (myCodeFragment.getContainingFile() == codeFragment.getContainingFile() &&  // in order for jsp includes to work
-        !myCodeFragment.equals(codeFragment)) {
-      return null;
-    }
-    return (PsiVariable)refElement;
-  }
-
-  @Override
-  public boolean isParameterAccepted(PsiParameter psiParameter) {
-    return checkCodeFragment(psiParameter) != null;
-  }
-
-  @Override
-  public boolean isLocalVariableAccepted(PsiLocalVariable psiVariable) {
-    return checkCodeFragment(psiVariable) != null;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java b/java/java-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java
deleted file mode 100644
index 7d11223..0000000
--- a/java/java-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java
+++ /dev/null
@@ -1,171 +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.psi.impl;
-
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.util.Function;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.List;
-
-/**
- * User: anna
- */
-public class PsiDiamondTypeUtil {
-  private static final Logger LOG = Logger.getInstance("#" + PsiDiamondTypeUtil.class.getName());
-
-  private PsiDiamondTypeUtil() {
-  }
-
-  public static boolean canCollapseToDiamond(final PsiNewExpression expression,
-                                             final PsiNewExpression context,
-                                             final @Nullable PsiType expectedType) {
-    return canCollapseToDiamond(expression, context, expectedType, false);
-  }
-
-  public static boolean canChangeContextForDiamond(final PsiNewExpression expression, final PsiType expectedType) {
-    final PsiNewExpression copy = (PsiNewExpression)expression.copy();
-    return canCollapseToDiamond(copy, copy, expectedType, true);
-  }
-
-  private static boolean canCollapseToDiamond(final PsiNewExpression expression,
-                                             final PsiNewExpression context,
-                                             final @Nullable PsiType expectedType,
-                                             boolean skipDiamonds) {
-    if (PsiUtil.getLanguageLevel(context).isAtLeast(LanguageLevel.JDK_1_7)) {
-      final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference();
-      if (classReference != null) {
-        final PsiReferenceParameterList parameterList = classReference.getParameterList();
-        if (parameterList != null) {
-          final PsiTypeElement[] typeElements = parameterList.getTypeParameterElements();
-          if (typeElements.length > 0) {
-            if (!skipDiamonds && typeElements.length == 1 && typeElements[0].getType() instanceof PsiDiamondType) return false;
-            final PsiDiamondTypeImpl.DiamondInferenceResult inferenceResult = PsiDiamondTypeImpl.resolveInferredTypes(expression, context);
-            if (inferenceResult.getErrorMessage() == null) {
-              final List<PsiType> types = inferenceResult.getInferredTypes();
-              PsiType[] typeArguments = null;
-              if (expectedType instanceof PsiClassType) {
-                typeArguments = ((PsiClassType)expectedType).getParameters();
-              }
-              if (typeArguments == null) {
-                typeArguments = parameterList.getTypeArguments();
-              }
-              if (types.size() == typeArguments.length) {
-                for (int i = 0, typeArgumentsLength = typeArguments.length; i < typeArgumentsLength; i++) {
-                  PsiType typeArgument = typeArguments[i];
-                  if (types.get(i) instanceof PsiWildcardType) {
-                    final PsiWildcardType wildcardType = (PsiWildcardType)types.get(i);
-                    final PsiType bound = wildcardType.getBound();
-                    if (bound != null) {
-                      if (wildcardType.isExtends()) {
-                        if (bound.isAssignableFrom(typeArgument)) continue;
-                      }
-                      else {
-                        if (typeArgument.isAssignableFrom(bound)) continue;
-                      }
-                    }
-                  }
-                  if (!typeArgument.equals(types.get(i))) {
-                    return false;
-                  }
-                }
-              }
-              return true;
-            }
-          }
-        }
-      }
-    }
-    return false;
-  }
-
-  public static PsiElement replaceExplicitWithDiamond(PsiElement psiElement) {
-    if (psiElement instanceof PsiReferenceParameterList) {
-      if (!FileModificationService.getInstance().prepareFileForWrite(psiElement.getContainingFile())) return psiElement;
-      final PsiNewExpression expression =
-        (PsiNewExpression)JavaPsiFacade.getElementFactory(psiElement.getProject()).createExpressionFromText("new a<>()", psiElement);
-      final PsiJavaCodeReferenceElement classReference = expression.getClassReference();
-      LOG.assertTrue(classReference != null);
-      final PsiReferenceParameterList parameterList = classReference.getParameterList();
-      LOG.assertTrue(parameterList != null);
-      return psiElement.replace(parameterList);
-    }
-    return psiElement;
-  }
-
-  public static PsiElement replaceDiamondWithExplicitTypes(PsiElement element) {
-    final PsiElement parent = element.getParent();
-    if (!(parent instanceof PsiJavaCodeReferenceElement)) {
-      return parent;
-    }
-    final PsiJavaCodeReferenceElement javaCodeReferenceElement =
-            (PsiJavaCodeReferenceElement) parent;
-    final PsiReferenceParameterList referenceParameterList =
-            (PsiReferenceParameterList) element;
-    final StringBuilder text = new StringBuilder();
-    text.append(javaCodeReferenceElement.getQualifiedName());
-    text.append('<');
-    final PsiTypeElement[] typeElements = referenceParameterList.getTypeParameterElements();
-    final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(typeElements[0], PsiNewExpression.class);
-    final PsiDiamondType.DiamondInferenceResult result = PsiDiamondTypeImpl.resolveInferredTypesNoCheck(newExpression, newExpression);
-    text.append(StringUtil.join(result.getInferredTypes(), new Function<PsiType, String>() {
-      @Override
-      public String fun(PsiType psiType) {
-        return psiType.getCanonicalText();
-      }
-    }, ","));
-    text.append('>');
-    final PsiElementFactory elementFactory =
-            JavaPsiFacade.getElementFactory(element.getProject());
-    final PsiJavaCodeReferenceElement newReference =
-            elementFactory.createReferenceFromText(text.toString(), element);
-    return CodeStyleManager.getInstance(javaCodeReferenceElement.getProject()).reformat(javaCodeReferenceElement.replace(newReference));
-  }
-
-  public static PsiExpression expandTopLevelDiamondsInside(PsiExpression expr) {
-    if (expr instanceof PsiNewExpression) {
-      final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)expr).getClassReference();
-      if (classReference != null) {
-        final PsiReferenceParameterList parameterList = classReference.getParameterList();
-        if (parameterList != null) {
-          final PsiTypeElement[] typeParameterElements = parameterList.getTypeParameterElements();
-          if (typeParameterElements.length == 1 && typeParameterElements[0].getType() instanceof PsiDiamondType) {
-            return  (PsiExpression)replaceDiamondWithExplicitTypes(parameterList).getParent();
-          }
-        }
-      }
-    }
-    return expr;
-  }
-
-  public static String getCollapsedType(PsiType type, PsiElement context) {
-    String typeText = type.getCanonicalText();
-    if (PsiUtil.isLanguageLevel7OrHigher(context)) {
-      final int idx = typeText.indexOf('<');
-      if (idx >= 0) {
-        return typeText.substring(0, idx) + "<>";
-      }
-    }
-    return typeText;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/psi/impl/light/LightParameter.java b/java/java-impl/src/com/intellij/psi/impl/light/LightParameter.java
index 611992b..6f5b426 100644
--- a/java/java-impl/src/com/intellij/psi/impl/light/LightParameter.java
+++ b/java/java-impl/src/com/intellij/psi/impl/light/LightParameter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
   private final boolean myVarArgs;
 
   public LightParameter(@NotNull String name, @NotNull PsiType type, PsiElement declarationScope, Language language) {
-    this(name, type, declarationScope, language, false);
+    this(name, type, declarationScope, language, type instanceof PsiEllipsisType);
   }
 
   public LightParameter(@NotNull String name, @NotNull PsiType type, PsiElement declarationScope, Language language, boolean isVarArgs) {
diff --git a/java/java-impl/src/com/intellij/psi/impl/smartPointers/ImplicitVariableElementInfoFactory.java b/java/java-impl/src/com/intellij/psi/impl/smartPointers/ImplicitVariableElementInfoFactory.java
index a75bca9..4239f03 100644
--- a/java/java-impl/src/com/intellij/psi/impl/smartPointers/ImplicitVariableElementInfoFactory.java
+++ b/java/java-impl/src/com/intellij/psi/impl/smartPointers/ImplicitVariableElementInfoFactory.java
@@ -15,16 +15,11 @@
  */
 package com.intellij.psi.impl.smartPointers;
 
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.RangeMarker;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Segment;
-import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.ImplicitVariable;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiIdentifier;
-import com.intellij.psi.util.PsiUtilCore;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -38,69 +33,25 @@
     return null;
   }
 
-  private static class ImplicitVariableInfo implements SmartPointerElementInfo {
-    private final ImplicitVariable myVar;
-    private final Project myProject;
-
+  private static class ImplicitVariableInfo extends HardElementInfo {
     public ImplicitVariableInfo(@NotNull ImplicitVariable var, @NotNull Project project) {
-      myVar = var;
-      myProject = project;
+      super(project, var);
     }
 
     @Override
     public PsiElement restoreElement() {
+      ImplicitVariable myVar = (ImplicitVariable)super.restoreElement();
       PsiIdentifier psiIdentifier = myVar.getNameIdentifier();
       if (psiIdentifier == null || psiIdentifier.isValid()) return myVar;
       return null;
     }
 
     @Override
-    @Nullable
-    public Document getDocumentToSynchronize() {
-      return null;
-    }
-
-    @Override
-    public void documentAndPsiInSync() {
-    }
-
-    @Override
-    public void fastenBelt(int offset, RangeMarker[] cachedRangeMarker) {
-    }
-
-    @Override
-    public void unfastenBelt(int offset) {
-    }
-
-    @Override
-    public int elementHashCode() {
-      return myVar.hashCode();
-    }
-
-    @Override
-    public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
-      if (other instanceof ImplicitVariableInfo) {
-        return myVar == ((ImplicitVariableInfo)other).myVar;
-      }
-      return Comparing.equal(restoreElement(), other.restoreElement());
-    }
-
-    @Override
-    public VirtualFile getVirtualFile() {
-      return PsiUtilCore.getVirtualFile(myVar);
-    }
-
-    @Override
     public Segment getRange() {
+      ImplicitVariable myVar = (ImplicitVariable)super.restoreElement();
       PsiIdentifier psiIdentifier = myVar.getNameIdentifier();
       if (psiIdentifier == null || !psiIdentifier.isValid()) return null;
       return psiIdentifier.getTextRange();
     }
-
-    @NotNull
-    @Override
-    public Project getProject() {
-      return myProject;
-    }
   }
 }
diff --git a/java/java-impl/src/com/intellij/psi/impl/smartPointers/SmartTypePointerManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/smartPointers/SmartTypePointerManagerImpl.java
deleted file mode 100644
index 3eaf7a4..0000000
--- a/java/java-impl/src/com/intellij/psi/impl/smartPointers/SmartTypePointerManagerImpl.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.psi.impl.smartPointers;
-
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.PsiSubstitutorImpl;
-import com.intellij.psi.impl.source.PsiClassReferenceType;
-import com.intellij.psi.impl.source.PsiImmediateClassType;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.reference.SoftReference;
-import com.intellij.util.Function;
-import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.NullableFunction;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.HashMap;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.lang.ref.Reference;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author max
- */
-public class SmartTypePointerManagerImpl extends SmartTypePointerManager {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.smartPointers.SmartTypePointerManagerImpl");
-
-  private static final SmartTypePointer NULL_POINTER = new SmartTypePointer() {
-    @Override
-    public PsiType getType() { return null; }
-  };
-
-  private final SmartPointerManager myPsiPointerManager;
-  private final Project myProject;
-
-  public SmartTypePointerManagerImpl(final SmartPointerManager psiPointerManager, final Project project) {
-    myPsiPointerManager = psiPointerManager;
-    myProject = project;
-  }
-
-  @Override
-  @NotNull
-  public SmartTypePointer createSmartTypePointer(@NotNull PsiType type) {
-    final SmartTypePointer pointer = type.accept(new SmartTypeCreatingVisitor());
-    return pointer != null ? pointer : NULL_POINTER;
-  }
-
-  private static class SimpleTypePointer implements SmartTypePointer {
-    private final PsiType myType;
-
-    private SimpleTypePointer(@NotNull PsiType type) {
-      myType = type;
-    }
-
-    @Override
-    public PsiType getType() {
-      return myType;
-    }
-  }
-
-  private static class ArrayTypePointer extends TypePointerBase<PsiArrayType> {
-    private final SmartTypePointer myComponentTypePointer;
-
-    public ArrayTypePointer(@NotNull PsiArrayType type, @NotNull SmartTypePointer componentTypePointer) {
-      super(type);
-      myComponentTypePointer = componentTypePointer;
-    }
-
-    @Nullable
-    @Override
-    protected PsiArrayType calcType() {
-      final PsiType type = myComponentTypePointer.getType();
-      return type == null ? null : new PsiArrayType(type);
-    }
-  }
-
-  private static class WildcardTypePointer extends TypePointerBase<PsiWildcardType> {
-    private final PsiManager myManager;
-    private final SmartTypePointer myBoundPointer;
-    private final boolean myIsExtending;
-
-    public WildcardTypePointer(@NotNull PsiWildcardType type, @Nullable SmartTypePointer boundPointer) {
-      super(type);
-      myManager = type.getManager();
-      myBoundPointer = boundPointer;
-      myIsExtending = type.isExtends();
-    }
-
-    @Override
-    protected PsiWildcardType calcType() {
-      if (myBoundPointer == null) {
-        return PsiWildcardType.createUnbounded(myManager);
-      }
-      else {
-        final PsiType type = myBoundPointer.getType();
-        assert type != null : myBoundPointer;
-        if (myIsExtending) {
-          return PsiWildcardType.createExtends(myManager, type);
-        }
-        return PsiWildcardType.createSuper(myManager, type);
-      }
-    }
-  }
-
-  private static class ClassTypePointer extends TypePointerBase<PsiClassType> {
-    private final SmartPsiElementPointer myClass;
-    private final Map<SmartPsiElementPointer, SmartTypePointer> myMap;
-
-    public ClassTypePointer(@NotNull PsiClassType type, @NotNull SmartPsiElementPointer aClass, @NotNull Map<SmartPsiElementPointer, SmartTypePointer> map) {
-      super(type);
-      myClass = aClass;
-      myMap = map;
-    }
-
-    @Override
-    protected PsiClassType calcType() {
-      final PsiElement classElement = myClass.getElement();
-      if (!(classElement instanceof PsiClass)) return null;
-      Map<PsiTypeParameter, PsiType> resurrected = new HashMap<PsiTypeParameter, PsiType>();
-      final Set<Map.Entry<SmartPsiElementPointer, SmartTypePointer>> set = myMap.entrySet();
-      for (Map.Entry<SmartPsiElementPointer, SmartTypePointer> entry : set) {
-        PsiElement element = entry.getKey().getElement();
-        if (element instanceof PsiTypeParameter) {
-          SmartTypePointer typePointer = entry.getValue();
-          resurrected.put((PsiTypeParameter)element, typePointer == null ? null : typePointer.getType());
-        }
-      }
-      for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable((PsiClass)classElement)) {
-        if (!resurrected.containsKey(typeParameter)) {
-          resurrected.put(typeParameter, null);
-        }
-      }
-      final PsiSubstitutor resurrectedSubstitutor = PsiSubstitutorImpl.createSubstitutor(resurrected);
-      return new PsiImmediateClassType((PsiClass)classElement, resurrectedSubstitutor);
-    }
-  }
-
-  private abstract static class TypePointerBase<T extends PsiType> implements SmartTypePointer {
-    private Reference<T> myTypeRef;
-
-    TypePointerBase(@NotNull T type) {
-      myTypeRef = new SoftReference<T>(type);
-    }
-
-    @Override
-    public T getType() {
-      Reference<T> typeRef = myTypeRef;
-      T myType = typeRef == null ? null : typeRef.get();
-      if (myType != null && myType.isValid()) return myType;
-
-      myType = calcType();
-      myTypeRef = myType == null ? null : new SoftReference<T>(myType);
-      return myType;
-    }
-
-    @Nullable
-    protected abstract T calcType();
-  }
-
-  private class ClassReferenceTypePointer extends TypePointerBase<PsiClassReferenceType> {
-    private final SmartPsiElementPointer mySmartPsiElementPointer;
-    private final String myReferenceText;
-
-    ClassReferenceTypePointer(@NotNull PsiClassReferenceType type) {
-      super(type);
-      final PsiJavaCodeReferenceElement reference = type.getReference();
-      mySmartPsiElementPointer = myPsiPointerManager.createSmartPsiElementPointer(reference);
-      myReferenceText = reference.getText();
-    }
-
-    @Override
-    protected PsiClassReferenceType calcType() {
-      PsiClassReferenceType myType = null;
-      final PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)mySmartPsiElementPointer.getElement();
-      final PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();
-      if (referenceElement != null) {
-        myType = (PsiClassReferenceType)factory.createType(referenceElement);
-      }
-      else {
-        try {
-          myType = (PsiClassReferenceType)factory.createTypeFromText(myReferenceText, null);
-        }
-        catch (IncorrectOperationException e) {
-          LOG.error(e);
-        }
-      }
-      return myType;
-    }
-  }
-
-  private class DisjunctionTypePointer extends TypePointerBase<PsiDisjunctionType> {
-    private final List<SmartTypePointer> myPointers;
-
-    private DisjunctionTypePointer(@NotNull PsiDisjunctionType type) {
-      super(type);
-      myPointers = ContainerUtil.map(type.getDisjunctions(), new Function<PsiType, SmartTypePointer>() {
-        @Override
-        public SmartTypePointer fun(PsiType psiType) {
-          return createSmartTypePointer(psiType);
-        }
-      });
-    }
-
-    @Override
-    protected PsiDisjunctionType calcType() {
-      final List<PsiType> types = ContainerUtil.map(myPointers, new NullableFunction<SmartTypePointer, PsiType>() {
-        @Override public PsiType fun(SmartTypePointer typePointer) { return typePointer.getType(); }
-      });
-      return new PsiDisjunctionType(types, PsiManager.getInstance(myProject));
-    }
-  }
-
-  private class SmartTypeCreatingVisitor extends PsiTypeVisitor<SmartTypePointer> {
-    @Override
-    public SmartTypePointer visitPrimitiveType(PsiPrimitiveType primitiveType) {
-      return new SimpleTypePointer(primitiveType);
-    }
-
-    @Override
-    public SmartTypePointer visitArrayType(PsiArrayType arrayType) {
-      final SmartTypePointer componentTypePointer = arrayType.getComponentType().accept(this);
-      return componentTypePointer != null ? new ArrayTypePointer(arrayType, componentTypePointer) : null;
-    }
-
-    @Override
-    public SmartTypePointer visitWildcardType(PsiWildcardType wildcardType) {
-      final PsiType bound = wildcardType.getBound();
-      final SmartTypePointer boundPointer = bound == null ? null : bound.accept(this);
-      return new WildcardTypePointer(wildcardType, boundPointer);
-    }
-
-    @Override
-    public SmartTypePointer visitClassType(PsiClassType classType) {
-      final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
-      final PsiClass aClass = resolveResult.getElement();
-      if (aClass == null) {
-        if (classType instanceof PsiClassReferenceType) {
-          return new ClassReferenceTypePointer((PsiClassReferenceType)classType);
-        }
-        return new SimpleTypePointer(classType);
-      }
-      if (classType instanceof PsiClassReferenceType) {
-        classType = ((PsiClassReferenceType)classType).createImmediateCopy();
-      }
-      final PsiSubstitutor substitutor = resolveResult.getSubstitutor();
-      final HashMap<SmartPsiElementPointer, SmartTypePointer> map = new HashMap<SmartPsiElementPointer, SmartTypePointer>();
-      for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(aClass)) {
-        final PsiType substitutionResult = substitutor.substitute(typeParameter);
-        if (substitutionResult != null) {
-          final SmartPsiElementPointer pointer = myPsiPointerManager.createSmartPsiElementPointer(typeParameter);
-          map.put(pointer, substitutionResult.accept(this));
-        }
-      }
-      return new ClassTypePointer(classType, myPsiPointerManager.createSmartPsiElementPointer(aClass), map);
-    }
-
-    @Override
-    public SmartTypePointer visitDisjunctionType(PsiDisjunctionType disjunctionType) {
-      return new DisjunctionTypePointer(disjunctionType);
-    }
-  }
-}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ReferenceAdjuster.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ReferenceAdjuster.java
index a25476a..0f9e286 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ReferenceAdjuster.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ReferenceAdjuster.java
@@ -207,15 +207,15 @@
 
   private static ASTNode makeShortReference(@NotNull CompositeElement reference, @NotNull PsiClass refClass, boolean addImports) {
     @NotNull final PsiJavaCodeReferenceElement psiReference = (PsiJavaCodeReferenceElement)reference.getPsi();
-    final PsiQualifiedReference reference1 = getClassReferenceToShorten(refClass, addImports, psiReference);
+    final PsiQualifiedReferenceElement reference1 = getClassReferenceToShorten(refClass, addImports, psiReference);
     if (reference1 != null) replaceReferenceWithShort(reference1);
     return reference;
   }
 
   @Nullable
-  public static PsiQualifiedReference getClassReferenceToShorten(@NotNull final PsiClass refClass,
+  public static PsiQualifiedReferenceElement getClassReferenceToShorten(@NotNull final PsiClass refClass,
                                                                  final boolean addImports,
-                                                                 @NotNull final PsiQualifiedReference reference) {
+                                                                 @NotNull final PsiQualifiedReferenceElement reference) {
     PsiClass parentClass = refClass.getContainingClass();
     if (parentClass != null) {
       JavaPsiFacade facade = JavaPsiFacade.getInstance(parentClass.getProject());
@@ -227,7 +227,7 @@
       if (!CodeStyleSettingsManager.getSettings(reference.getProject()).INSERT_INNER_CLASS_IMPORTS) {
         final PsiElement qualifier = reference.getQualifier();
         if (qualifier instanceof PsiQualifiedReference) {
-          return getClassReferenceToShorten(parentClass, addImports, (PsiQualifiedReference)qualifier);
+          return getClassReferenceToShorten(parentClass, addImports, (PsiQualifiedReferenceElement)qualifier);
         }
         return null;
       }
@@ -255,7 +255,7 @@
   }
 
   @NotNull
-  private static ASTNode replaceReferenceWithShort(PsiQualifiedReference reference) {
+  private static ASTNode replaceReferenceWithShort(PsiQualifiedReferenceElement reference) {
     ASTNode node = reference.getNode();
     assert node != null;
     deQualifyImpl((CompositeElement)node);
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/JavaTreeGenerator.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/JavaTreeGenerator.java
index 6e34ca2..f6ba9fd 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/tree/JavaTreeGenerator.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/tree/JavaTreeGenerator.java
@@ -114,10 +114,10 @@
     if (original instanceof PsiCompiledElement) {
       PsiElement sourceVersion = original.getNavigationElement();
       if (sourceVersion != original) {
-        return ChangeUtil.generateTreeElement(sourceVersion, table,manager);
+        return ChangeUtil.generateTreeElement(sourceVersion, table, manager);
       }
-      ASTNode mirror = SourceTreeToPsiMap.psiElementToTree(((PsiCompiledElement)original).getMirror());
-      return ChangeUtil.generateTreeElement(SourceTreeToPsiMap.treeElementToPsi(mirror), table,manager);
+      PsiElement mirror = ((PsiCompiledElement)original).getMirror();
+      return ChangeUtil.generateTreeElement(mirror, table, manager);
     }
 
     if (original instanceof PsiTypeElement) {
diff --git a/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerDialog.java b/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerDialog.java
index 3f6d158..7bca3c0 100644
--- a/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerDialog.java
@@ -30,6 +30,7 @@
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.refactoring.util.ParameterTablePanel;
 import com.intellij.refactoring.util.RefactoringMessageUtil;
+import com.intellij.refactoring.util.VariableData;
 import com.intellij.ui.IdeBorderFactory;
 import com.intellij.ui.NonFocusableCheckBox;
 import com.intellij.util.Function;
@@ -49,7 +50,7 @@
   private final boolean myShowCanBeStatic;
 
   private NameSuggestionsField myNameField;
-  private final ParameterTablePanel.VariableData[] myVariableData;
+  private final VariableData[] myVariableData;
   private final Map<PsiVariable,VariableInfo> myVariableToInfoMap = new HashMap<PsiVariable, VariableInfo>();
   private JCheckBox myCbMakeStatic;
 
@@ -65,7 +66,7 @@
     for (VariableInfo info : variableInfos) {
       myVariableToInfoMap.put(info.variable, info);
     }
-    myVariableData = new ParameterTablePanel.VariableData[variableInfos.length];
+    myVariableData = new VariableData[variableInfos.length];
 
     final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(myProject);
     for(int idx = 0; idx < variableInfos.length; idx++){
@@ -74,7 +75,7 @@
       VariableKind kind = codeStyleManager.getVariableKind(info.variable);
       name = codeStyleManager.variableNameToPropertyName(name, kind);
       name = codeStyleManager.propertyNameToVariableName(name, VariableKind.PARAMETER);
-      ParameterTablePanel.VariableData data = new ParameterTablePanel.VariableData(info.variable);
+      VariableData data = new VariableData(info.variable);
       data.name = name;
       data.passAsParameter = true;
       myVariableData[idx] = data;
@@ -127,7 +128,7 @@
     JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(myProject);
     VariableInfo[] infos = new VariableInfo[myVariableData.length];
     for (int idx = 0; idx < myVariableData.length; idx++) {
-      ParameterTablePanel.VariableData data = myVariableData[idx];
+      VariableData data = myVariableData[idx];
       VariableInfo info = myVariableToInfoMap.get(data.variable);
 
       info.passAsParameter = data.passAsParameter;
diff --git a/java/java-impl/src/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureDialog.java b/java/java-impl/src/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureDialog.java
index f8ff36b..f8e27c4 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureDialog.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.refactoring.changeClassSignature;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
@@ -27,7 +28,6 @@
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.ui.*;
 import com.intellij.ui.table.JBTable;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.ui.EditableModel;
 import org.jetbrains.annotations.NotNull;
@@ -116,7 +116,7 @@
   }
 
   protected JComponent createNorthPanel() {
-    return new JLabel(RefactoringBundle.message("changeClassSignature.class.label.text", UsageViewUtil.getDescriptiveName(myClass)));
+    return new JLabel(RefactoringBundle.message("changeClassSignature.class.label.text", DescriptiveNameUtil.getDescriptiveName(myClass)));
   }
 
   @Override
diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/DetectedJavaChangeInfo.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/DetectedJavaChangeInfo.java
index e1ad62f..250efce 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeSignature/DetectedJavaChangeInfo.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/DetectedJavaChangeInfo.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.refactoring.changeSignature;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.command.CommandProcessor;
 import com.intellij.openapi.editor.Document;
@@ -25,7 +26,6 @@
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.util.CanonicalTypes;
 import com.intellij.usageView.UsageInfo;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.VisibilityUtil;
 import org.jetbrains.annotations.NotNull;
@@ -288,7 +288,7 @@
               temporallyRevertChanges(method, oldText);
               doRefactor(processor);
             }
-          }, RefactoringBundle.message("changing.signature.of.0", UsageViewUtil.getDescriptiveName(currentMethod)), null);
+          }, RefactoringBundle.message("changing.signature.of.0", DescriptiveNameUtil.getDescriptiveName(currentMethod)), null);
         }
 
         private void doRefactor(BaseRefactoringProcessor processor) {
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 e480912..cc4d0cd 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java
@@ -16,6 +16,7 @@
 package com.intellij.refactoring.changeSignature;
 
 import com.intellij.codeInsight.ExceptionUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.lang.StdLanguages;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
@@ -245,7 +246,7 @@
 
     if (toCatchExceptions) {
       if (!(ref instanceof PsiReferenceExpression &&
-            RefactoringUtil.isSuperOrThisCall(PsiTreeUtil.getParentOfType(ref, PsiStatement.class), true, false))) {
+            JavaHighlightUtil.isSuperOrThisCall(PsiTreeUtil.getParentOfType(ref, PsiStatement.class), true, false))) {
         if (needToCatchExceptions(changeInfo, caller)) {
           PsiClassType[] newExceptions =
             callee != null ? getCalleeChangedExceptionInfo(callee) : getPrimaryChangedExceptionInfo(changeInfo);
diff --git a/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java b/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java
index c3b911b..180e28d 100644
--- a/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java
@@ -16,6 +16,7 @@
  */
 package com.intellij.refactoring.encapsulateFields;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
@@ -75,7 +76,7 @@
   }
 
   protected String getCommandName() {
-    return RefactoringBundle.message("encapsulate.fields.command.name", UsageViewUtil.getDescriptiveName(myClass));
+    return RefactoringBundle.message("encapsulate.fields.command.name", DescriptiveNameUtil.getDescriptiveName(myClass));
   }
 
   protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages) {
diff --git a/java/java-impl/src/com/intellij/refactoring/extractInterface/ExtractInterfaceHandler.java b/java/java-impl/src/com/intellij/refactoring/extractInterface/ExtractInterfaceHandler.java
index 1e2448e..061d04e 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractInterface/ExtractInterfaceHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractInterface/ExtractInterfaceHandler.java
@@ -17,6 +17,7 @@
 
 import com.intellij.history.LocalHistory;
 import com.intellij.history.LocalHistoryAction;
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.command.CommandProcessor;
@@ -34,7 +35,6 @@
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.refactoring.util.DocCommentPolicy;
 import com.intellij.refactoring.util.classMembers.MemberInfo;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.MultiMap;
@@ -150,7 +150,7 @@
   }
 
   private String getCommandName() {
-    return RefactoringBundle.message("extract.interface.command.name", myInterfaceName, UsageViewUtil.getDescriptiveName(myClass));
+    return RefactoringBundle.message("extract.interface.command.name", myInterfaceName, DescriptiveNameUtil.getDescriptiveName(myClass));
   }
 
   public boolean isEnabledOnElements(PsiElement[] elements) {
diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractDialog.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractDialog.java
index 2e4531c..7e49181 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractDialog.java
@@ -23,7 +23,7 @@
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.psi.PsiModifier;
-import com.intellij.refactoring.util.ParameterTablePanel;
+import com.intellij.refactoring.util.VariableData;
 
 public abstract class AbstractExtractDialog extends DialogWrapper {
   protected AbstractExtractDialog(Project project) {
@@ -33,7 +33,7 @@
 
   public abstract String getChosenMethodName();
 
-  public abstract ParameterTablePanel.VariableData[] getChosenParameters();
+  public abstract VariableData[] getChosenParameters();
 
   @PsiModifier.ModifierConstant
   public abstract String getVisibility();
diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java
index 5e64113..0f31912 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java
@@ -32,6 +32,7 @@
 import com.intellij.refactoring.ui.MethodSignatureComponent;
 import com.intellij.refactoring.util.ConflictsUtil;
 import com.intellij.refactoring.util.ParameterTablePanel;
+import com.intellij.refactoring.util.VariableData;
 import com.intellij.ui.EditorTextField;
 import com.intellij.ui.IdeBorderFactory;
 import com.intellij.ui.NonFocusableCheckBox;
@@ -81,7 +82,7 @@
   private final JCheckBox myFoldParameters = new NonFocusableCheckBox(RefactoringBundle.message("declare.folded.parameters"));
   public JPanel myCenterPanel;
   public JPanel myParamTable;
-  private ParameterTablePanel.VariableData[] myInputVariables;
+  private VariableData[] myInputVariables;
 
   public ExtractMethodDialog(Project project,
                              PsiClass targetClass, final InputVariables inputVariables, PsiType returnType,
@@ -156,7 +157,7 @@
     return myNameField.getText();
   }
 
-  public ParameterTablePanel.VariableData[] getChosenParameters() {
+  public VariableData[] getChosenParameters() {
     return myInputVariables;
   }
 
@@ -182,7 +183,7 @@
     }
 
     if (myMakeVarargs != null && myMakeVarargs.isSelected()) {
-      final ParameterTablePanel.VariableData data = myInputVariables[myInputVariables.length - 1];
+      final VariableData data = myInputVariables[myInputVariables.length - 1];
       if (data.type instanceof PsiArrayType) {
         data.type = new PsiEllipsisType(((PsiArrayType)data.type).getComponentType());
       }
@@ -243,12 +244,12 @@
     myFoldParameters.setSelected(myVariableData.isFoldingSelectedByDefault());
     myFoldParameters.setVisible(myVariableData.isFoldable());
     myVariableData.setFoldingAvailable(myFoldParameters.isSelected());
-    myInputVariables = myVariableData.getInputVariables().toArray(new ParameterTablePanel.VariableData[myVariableData.getInputVariables().size()]);
+    myInputVariables = myVariableData.getInputVariables().toArray(new VariableData[myVariableData.getInputVariables().size()]);
     myFoldParameters.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent e) {
         myVariableData.setFoldingAvailable(myFoldParameters.isSelected());
         myInputVariables =
-          myVariableData.getInputVariables().toArray(new ParameterTablePanel.VariableData[myVariableData.getInputVariables().size()]);
+          myVariableData.getInputVariables().toArray(new VariableData[myVariableData.getInputVariables().size()]);
         updateVarargsEnabled();
         createParametersPanel();
         updateSignature();
@@ -258,7 +259,7 @@
     myFoldParameters.setBorder(emptyBorder);
 
     boolean canBeVarargs = false;
-    for (ParameterTablePanel.VariableData data : myInputVariables) {
+    for (VariableData data : myInputVariables) {
       canBeVarargs |= data.type instanceof PsiArrayType;
     }
     if (myVariableData.isFoldable()) {
@@ -453,10 +454,10 @@
 
     final String INDENT = StringUtil.repeatSymbol(' ', buffer.length());
 
-    final ParameterTablePanel.VariableData[] datas = myInputVariables;
+    final VariableData[] datas = myInputVariables;
     int count = 0;
     for (int i = 0; i < datas.length;i++) {
-      ParameterTablePanel.VariableData data = datas[i];
+      VariableData data = datas[i];
       if (data.passAsParameter) {
         //String typeAndModifiers = PsiFormatUtil.formatVariable(data.variable,
         //  PsiFormatUtil.SHOW_MODIFIERS | PsiFormatUtil.SHOW_TYPE);
@@ -500,7 +501,7 @@
       PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();
       prototype = factory.createMethod(myNameField.getText().trim(), myReturnType);
       if (myTypeParameterList != null) prototype.getTypeParameterList().replace(myTypeParameterList);
-      for (ParameterTablePanel.VariableData data : myInputVariables) {
+      for (VariableData data : myInputVariables) {
         if (data.passAsParameter) {
           prototype.getParameterList().add(factory.createParameter(data.name, data.type));
         }
diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java
index 70d031b..21de8fc 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java
@@ -16,6 +16,7 @@
 package com.intellij.refactoring.extractMethod;
 
 import com.intellij.codeInsight.CodeInsightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.highlighting.HighlightManager;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.actionSystem.LangDataKeys;
@@ -80,8 +81,7 @@
     editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
     if (!editor.getSelectionModel().hasSelection()) {
       final int offset = editor.getCaretModel().getOffset();
-      final PsiElement[] statementsInRange = IntroduceVariableBase.findStatementsAtOffset(editor, file, offset);
-      final List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(file, editor, offset, statementsInRange);
+      final List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(file, editor, offset, true);
       if (expressions.isEmpty()) {
         editor.getSelectionModel().selectLineAtCaret();
       }
@@ -166,7 +166,7 @@
                                                      final Project project,
                                                      final PsiFile file,
                                                      final Editor editor,
-                                                     final boolean showErrorMessages, 
+                                                     final boolean showErrorMessages,
                                                      final @Nullable Pass<ExtractMethodProcessor> pass) {
     if (elements == null || elements.length == 0) {
       if (showErrorMessages) {
@@ -178,7 +178,7 @@
     }
 
     for (PsiElement element : elements) {
-      if (element instanceof PsiStatement && RefactoringUtil.isSuperOrThisCall((PsiStatement)element, true, true)) {
+      if (element instanceof PsiStatement && JavaHighlightUtil.isSuperOrThisCall((PsiStatement)element, true, true)) {
         if (showErrorMessages) {
           String message = RefactoringBundle
             .getCannotRefactorMessage(RefactoringBundle.message("selected.block.contains.invocation.of.another.class.constructor"));
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 14535e0..7279f90 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
@@ -18,6 +18,7 @@
 import com.intellij.codeInsight.ChangeContextUtil;
 import com.intellij.codeInsight.ExceptionUtil;
 import com.intellij.codeInsight.NullableNotNullManager;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.highlighting.HighlightManager;
 import com.intellij.codeInsight.intention.impl.AddNullableAnnotationFix;
 import com.intellij.codeInsight.navigation.NavigationUtil;
@@ -66,10 +67,7 @@
 import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
 import com.intellij.refactoring.util.*;
 import com.intellij.refactoring.util.classMembers.ElementNeedsThis;
-import com.intellij.refactoring.util.duplicates.DuplicatesFinder;
-import com.intellij.refactoring.util.duplicates.Match;
-import com.intellij.refactoring.util.duplicates.MatchProvider;
-import com.intellij.refactoring.util.duplicates.VariableReturnValue;
+import com.intellij.refactoring.util.duplicates.*;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.Processor;
@@ -104,7 +102,7 @@
   protected String myMethodName; // name for extracted method
   protected PsiType myReturnType; // return type for extracted method
   protected PsiTypeParameterList myTypeParameterList; //type parameter list of extracted method
-  private ParameterTablePanel.VariableData[] myVariableDatum; // parameter data for extracted method
+  private VariableData[] myVariableDatum; // parameter data for extracted method
   protected PsiClassType[] myThrownExceptions; // exception to declare as thrown by extracted method
   protected boolean myStatic; // whether to declare extracted method static
 
@@ -446,7 +444,7 @@
   private boolean shouldBeStatic() {
     for(PsiElement element: myElements) {
       final PsiExpressionStatement statement = PsiTreeUtil.getParentOfType(element, PsiExpressionStatement.class);
-      if (statement != null && RefactoringUtil.isSuperOrThisCall(statement, true, true)) {
+      if (statement != null && JavaHighlightUtil.isSuperOrThisCall(statement, true, true)) {
         return true;
       }
     }
@@ -546,7 +544,7 @@
   public void testPrepare() {
     myInputVariables.setFoldingAvailable(myInputVariables.isFoldingSelectedByDefault());
     myMethodName = myInitialMethodName;
-    myVariableDatum = new ParameterTablePanel.VariableData[myInputVariables.getInputVariables().size()];
+    myVariableDatum = new VariableData[myInputVariables.getInputVariables().size()];
     for (int i = 0; i < myInputVariables.getInputVariables().size(); i++) {
       myVariableDatum[i] = myInputVariables.getInputVariables().get(i);
     }
@@ -805,7 +803,7 @@
 
     adjustFinalParameters(newMethod);
     int i = 0;
-    for (ParameterTablePanel.VariableData data : myVariableDatum) {
+    for (VariableData data : myVariableDatum) {
       if (!data.passAsParameter) continue;
       final PsiVariable variable = data.variable;
       final PsiParameter psiParameter = newMethod.getParameterList().getParameters()[i++];
@@ -926,20 +924,20 @@
   }
 
   public PsiElement processMatch(Match match) throws IncorrectOperationException {
-    match.changeSignature(myExtractedMethod);
+    MatchUtil.changeSignature(match, myExtractedMethod);
     if (RefactoringUtil.isInStaticContext(match.getMatchStart(), myExtractedMethod.getContainingClass())) {
       PsiUtil.setModifierProperty(myExtractedMethod, PsiModifier.STATIC, true);
     }
     final PsiMethodCallExpression methodCallExpression = generateMethodCall(match.getInstanceExpression(), false);
 
-    ArrayList<ParameterTablePanel.VariableData> datas = new ArrayList<ParameterTablePanel.VariableData>();
-    for (final ParameterTablePanel.VariableData variableData : myVariableDatum) {
+    ArrayList<VariableData> datas = new ArrayList<VariableData>();
+    for (final VariableData variableData : myVariableDatum) {
       if (variableData.passAsParameter) {
         datas.add(variableData);
       }
     }
     final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(myProject);
-    for (ParameterTablePanel.VariableData data : datas) {
+    for (VariableData data : datas) {
       final List<PsiElement> parameterValue = match.getParameterValues(data.variable);
       if (parameterValue != null) {
         for (PsiElement val : parameterValue) {
@@ -983,7 +981,7 @@
   }
 
   private void renameInputVariables() throws IncorrectOperationException {
-    for (ParameterTablePanel.VariableData data : myVariableDatum) {
+    for (VariableData data : myVariableDatum) {
       PsiVariable variable = data.variable;
       if (!data.name.equals(variable.getName())) {
         for (PsiElement element : myElements) {
@@ -1015,7 +1013,7 @@
 
     boolean isFinal = CodeStyleSettingsManager.getSettings(myProject).GENERATE_FINAL_PARAMETERS;
     PsiParameterList list = newMethod.getParameterList();
-    for (ParameterTablePanel.VariableData data : myVariableDatum) {
+    for (VariableData data : myVariableDatum) {
       if (data.passAsParameter) {
         PsiParameter parm = myElementFactory.createParameter(data.name, data.type);
         if (isFinal) {
@@ -1053,7 +1051,7 @@
         final PsiClass nullableAnnotationClass =
           JavaPsiFacade.getInstance(myProject).findClass(manager.getDefaultNullable(), GlobalSearchScope.allScope(myProject));
         if (nullableAnnotationClass != null) {
-          new AddNullableAnnotationFix(newMethod).invoke(myProject, myEditor, myTargetClass.getContainingFile());
+          new AddNullableAnnotationFix(newMethod).invoke(myProject, myTargetClass.getContainingFile(), newMethod, newMethod);
         }
       }
     }
@@ -1104,7 +1102,7 @@
     buffer.append("(");
     if (generateArgs) {
       int count = 0;
-      for (ParameterTablePanel.VariableData data : myVariableDatum) {
+      for (VariableData data : myVariableDatum) {
         if (data.passAsParameter) {
           if (count > 0) {
             buffer.append(",");
@@ -1252,7 +1250,7 @@
   }
 
   private String getNewVariableName(PsiVariable variable) {
-    for (ParameterTablePanel.VariableData data : myVariableDatum) {
+    for (VariableData data : myVariableDatum) {
       if (data.variable.equals(variable)) {
         return data.name;
       }
@@ -1373,7 +1371,8 @@
   @Nullable
   public String getConfirmDuplicatePrompt(Match match) {
     final boolean needToBeStatic = RefactoringUtil.isInStaticContext(match.getMatchStart(), myExtractedMethod.getContainingClass());
-    final String changedSignature = match.getChangedSignature(myExtractedMethod, needToBeStatic, VisibilityUtil.getVisibilityStringToDisplay(myExtractedMethod));
+    final String changedSignature = MatchUtil
+      .getChangedSignature(match, myExtractedMethod, needToBeStatic, VisibilityUtil.getVisibilityStringToDisplay(myExtractedMethod));
     if (changedSignature != null) {
       return RefactoringBundle.message("replace.this.code.fragment.and.change.signature", changedSignature);
     }
diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/InputVariables.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/InputVariables.java
deleted file mode 100644
index 441f908..0000000
--- a/java/java-impl/src/com/intellij/refactoring/extractMethod/InputVariables.java
+++ /dev/null
@@ -1,313 +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.
- */
-
-/*
- * User: anna
- * Date: 22-Jun-2009
- */
-package com.intellij.refactoring.extractMethod;
-
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Pair;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.codeStyle.VariableKind;
-import com.intellij.psi.controlFlow.ControlFlow;
-import com.intellij.psi.search.LocalSearchScope;
-import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.TypeConversionUtil;
-import com.intellij.refactoring.util.ParameterTablePanel;
-import com.intellij.refactoring.util.duplicates.DuplicatesFinder;
-import com.intellij.util.ArrayUtil;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.*;
-
-public class InputVariables {
-  private final List<ParameterTablePanel.VariableData> myInputVariables;
-
-  private List<? extends PsiVariable> myInitialParameters;
-  private final Project myProject;
-  private final LocalSearchScope myScope;
-
-  private ParametersFolder myFolding;
-  private boolean myFoldingAvailable;
-
-  public InputVariables(final List<? extends PsiVariable> inputVariables,
-                        Project project,
-                        LocalSearchScope scope,
-                        boolean foldingAvailable) {
-    myInitialParameters = inputVariables;
-    myProject = project;
-    myScope = scope;
-    myFoldingAvailable = foldingAvailable;
-    myFolding = new ParametersFolder();
-    myInputVariables = wrapInputVariables(inputVariables);
-  }
-
-  /**
-   * copy use only
-   */
-  public InputVariables(List<ParameterTablePanel.VariableData> inputVariables,
-                        Project project,
-                        LocalSearchScope scope) {
-    myProject = project;
-    myScope = scope;
-    myInputVariables = new ArrayList<ParameterTablePanel.VariableData>(inputVariables);
-  }
-
-  public boolean isFoldable() {
-    return myFolding.isFoldable();
-  }
-
-  public ArrayList<ParameterTablePanel.VariableData> wrapInputVariables(final List<? extends PsiVariable> inputVariables) {
-    final ArrayList<ParameterTablePanel.VariableData> inputData = new ArrayList<ParameterTablePanel.VariableData>(inputVariables.size());
-    for (PsiVariable var : inputVariables) {
-      String name = var.getName();
-      if (!(var instanceof PsiParameter)) {
-        JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(myProject);
-        VariableKind kind = codeStyleManager.getVariableKind(var);
-        name = codeStyleManager.variableNameToPropertyName(name, kind);
-        name = codeStyleManager.propertyNameToVariableName(name, VariableKind.PARAMETER);
-      }
-      PsiType type = var.getType();
-      if (type instanceof PsiEllipsisType) {
-        type = ((PsiEllipsisType)type).toArrayType();
-      }
-      final Map<PsiCodeBlock, PsiType> casts = new HashMap<PsiCodeBlock, PsiType>();
-      for (PsiReference reference : ReferencesSearch.search(var, myScope)) {
-        final PsiElement element = reference.getElement();
-        final PsiElement parent = element.getParent();
-        final PsiCodeBlock block = PsiTreeUtil.getParentOfType(parent, PsiCodeBlock.class);
-        if (parent instanceof PsiTypeCastExpression) {
-          final PsiType currentType = casts.get(block);
-          final PsiType castType = ((PsiTypeCastExpression)parent).getType();
-          casts.put(block, casts.containsKey(block) && currentType == null ? null : getBroaderType(currentType, castType));
-        } else {
-          casts.put(block, null);
-        }
-      }
-      if (!casts.containsValue(null)) {
-        PsiType currentType = null;
-        for (PsiType psiType : casts.values()) {
-          currentType = getBroaderType(currentType, psiType);
-          if (currentType == null) {
-            break;
-          }
-        }
-        if (currentType != null) {
-          currentType = checkTopLevelInstanceOf(currentType);
-          if (currentType != null) {
-            type = currentType;
-          }
-        }
-      }
-
-      ParameterTablePanel.VariableData data = new ParameterTablePanel.VariableData(var, type);
-      data.name = name;
-      data.passAsParameter = true;
-      inputData.add(data);
-
-      if (myFoldingAvailable) myFolding.isParameterFoldable(data, myScope, inputVariables);
-    }
-
-
-    if (myFoldingAvailable) {
-      final Set<ParameterTablePanel.VariableData> toDelete = new HashSet<ParameterTablePanel.VariableData>();
-      for (int i = inputData.size() - 1; i >=0; i--) {
-        final ParameterTablePanel.VariableData data = inputData.get(i);
-        if (myFolding.isParameterSafeToDelete(data, myScope)) {
-          toDelete.add(data);
-        }
-      }
-      inputData.removeAll(toDelete);
-    }
-
-
-    return inputData;
-  }
-
-  @Nullable
-  private PsiType checkTopLevelInstanceOf(final PsiType currentType) {
-    final PsiElement[] scope = myScope.getScope();
-    if (scope.length == 1 && scope[0] instanceof PsiIfStatement) {
-      final PsiExpression condition = ((PsiIfStatement)scope[0]).getCondition();
-      if (condition != null) {
-        class CheckInstanceOf {
-          boolean check(PsiInstanceOfExpression expr) {
-            final PsiTypeElement checkType = expr.getCheckType();
-            return checkType == null || !checkType.getType().equals(currentType);
-          }
-        }
-        CheckInstanceOf checker = new CheckInstanceOf();
-        final PsiInstanceOfExpression[] expressions = PsiTreeUtil.getChildrenOfType(condition, PsiInstanceOfExpression.class);
-        if (expressions != null) {
-          for (PsiInstanceOfExpression instanceOfExpression : expressions) {
-            if (!checker.check(instanceOfExpression)) return null;
-          }
-        } else if (condition instanceof PsiInstanceOfExpression) {
-           if (!checker.check((PsiInstanceOfExpression)condition)) return null;
-        }
-      }
-    }
-    return currentType;
-  }
-
-  @Nullable
-  private static PsiType getBroaderType(PsiType currentType, PsiType castType) {
-    if (currentType != null) {
-      if (castType != null) {
-        if (TypeConversionUtil.isAssignable(castType, currentType)) {
-          return castType;
-        } else if (!TypeConversionUtil.isAssignable(currentType, castType)) {
-          for (PsiType superType : castType.getSuperTypes()) {
-            if (TypeConversionUtil.isAssignable(superType, currentType)) {
-              return superType;
-            }
-          }
-          return null;
-        }
-      }
-    }
-    else {
-      return castType;
-    }
-    return currentType;
-  }
-
-  public List<ParameterTablePanel.VariableData> getInputVariables() {
-    return myInputVariables;
-  }
-
-  public PsiExpression replaceWrappedReferences(PsiElement[] elements, PsiExpression expression) {
-    if (!myFoldingAvailable) return expression;
-
-    boolean update = elements[0] == expression;
-    for (ParameterTablePanel.VariableData inputVariable : myInputVariables) {
-      myFolding.foldParameterUsagesInBody(inputVariable, elements, myScope);
-    }
-    return update ? (PsiExpression)elements[0] : expression;
-  }
-
-  public boolean toDeclareInsideBody(PsiVariable variable) {
-    final ArrayList<ParameterTablePanel.VariableData> knownVars = new ArrayList<ParameterTablePanel.VariableData>(myInputVariables);
-    for (ParameterTablePanel.VariableData data : knownVars) {
-      if (data.variable.equals(variable)) {
-        return false;
-      }
-    }
-    return !myFolding.wasExcluded(variable);
-  }
-
-  public boolean contains(PsiVariable variable) {
-    for (ParameterTablePanel.VariableData data : myInputVariables) {
-      if (data.variable.equals(variable)) return true;
-    }
-    return false;
-  }
-
-  public void removeParametersUsedInExitsOnly(PsiElement codeFragment,
-                                              Collection<PsiStatement> exitStatements,
-                                              ControlFlow controlFlow,
-                                              int startOffset,
-                                              int endOffset) {
-    final LocalSearchScope scope = new LocalSearchScope(codeFragment);
-    Variables:
-    for (Iterator<ParameterTablePanel.VariableData> iterator = myInputVariables.iterator(); iterator.hasNext();) {
-      final ParameterTablePanel.VariableData data = iterator.next();
-      for (PsiReference ref : ReferencesSearch.search(data.variable, scope)) {
-        PsiElement element = ref.getElement();
-        int elementOffset = controlFlow.getStartOffset(element);
-        if (elementOffset >= startOffset && elementOffset <= endOffset) {
-          if (!isInExitStatements(element, exitStatements)) continue Variables;
-        }
-      }
-      iterator.remove();
-    }
-  }
-
-  private static boolean isInExitStatements(PsiElement element, Collection<PsiStatement> exitStatements) {
-    for (PsiStatement exitStatement : exitStatements) {
-      if (PsiTreeUtil.isAncestor(exitStatement, element, false)) return true;
-    }
-    return false;
-  }
-
-
-  public InputVariables copy() {
-    final InputVariables inputVariables = new InputVariables(myInputVariables, myProject, myScope);
-    inputVariables.myFoldingAvailable = myFoldingAvailable;
-    inputVariables.myFolding = myFolding;
-    inputVariables.myInitialParameters = myInitialParameters;
-    return inputVariables;
-  }
-
-
-  public void appendCallArguments(ParameterTablePanel.VariableData data, StringBuilder buffer) {
-    if (myFoldingAvailable) {
-      buffer.append(myFolding.getGeneratedCallArgument(data));
-    } else {
-      if (!TypeConversionUtil.isAssignable(data.type, data.variable.getType())) {
-        buffer.append("(").append(data.type.getCanonicalText()).append(")");
-      }
-      buffer.append(data.variable.getName());
-    }
-  }
-
-  public void setFoldingAvailable(boolean foldingAvailable) {
-    myFoldingAvailable = foldingAvailable;
-
-    myFolding.clear();
-    myInputVariables.clear();
-    myInputVariables.addAll(wrapInputVariables(myInitialParameters));
-  }
-
-  public void annotateWithParameter(PsiJavaCodeReferenceElement reference) {
-    for (ParameterTablePanel.VariableData data : myInputVariables) {
-      final PsiElement element = reference.resolve();
-      if (data.variable.equals(element)) {
-        PsiType type = data.variable.getType();
-        final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(reference, PsiMethodCallExpression.class);
-        if (methodCallExpression != null) {
-          int idx = ArrayUtil.find(methodCallExpression.getArgumentList().getExpressions(), reference);
-          if (idx > -1) {
-            final PsiMethod psiMethod = methodCallExpression.resolveMethod();
-            if (psiMethod != null) {
-              final PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
-              if (idx >= parameters.length) { //vararg parameter
-                idx = parameters.length - 1;
-                if (idx >= 0) { //incomplete code
-                  type = parameters[idx].getType();
-                }
-              }
-              if (type instanceof PsiEllipsisType) {
-                type = ((PsiEllipsisType)type).getComponentType();
-              }
-            }
-          }
-        }
-        if (!myFoldingAvailable || !myFolding.annotateWithParameter(data, reference)) {
-          reference.putUserData(DuplicatesFinder.PARAMETER, Pair.create(data.variable, type));
-        }
-      }
-    }
-  }
-
-  public boolean isFoldingSelectedByDefault() {
-    return myFolding.isFoldingSelectedByDefault();
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ParametersFolder.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ParametersFolder.java
deleted file mode 100644
index a6fed17..0000000
--- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ParametersFolder.java
+++ /dev/null
@@ -1,313 +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.
- */
-
-/*
- * User: anna
- * Date: 23-Jun-2009
- */
-package com.intellij.refactoring.extractMethod;
-
-import com.intellij.codeInsight.PsiEquivalenceUtil;
-import com.intellij.openapi.util.Pair;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.codeStyle.SuggestedNameInfo;
-import com.intellij.psi.codeStyle.VariableKind;
-import com.intellij.psi.search.LocalSearchScope;
-import com.intellij.psi.search.SearchScope;
-import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.refactoring.util.ParameterTablePanel;
-import com.intellij.refactoring.util.duplicates.DuplicatesFinder;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.*;
-
-public class ParametersFolder {
-  private final Map<PsiVariable, PsiExpression> myExpressions = new HashMap<PsiVariable, PsiExpression>();
-  private final Map<PsiVariable, List<PsiExpression>> myMentionedInExpressions = new HashMap<PsiVariable, List<PsiExpression>>();
-  private final Set<String> myUsedNames = new HashSet<String>();
-
-  private final Set<PsiVariable> myDeleted = new HashSet<PsiVariable>();
-  private boolean myFoldingSelectedByDefault = false;
-
-
-  public void clear() {
-    myExpressions.clear();
-    myMentionedInExpressions.clear();
-    myUsedNames.clear();
-    myDeleted.clear();
-  }
-
-  public boolean isParameterSafeToDelete(@NotNull ParameterTablePanel.VariableData data, @NotNull LocalSearchScope scope) {
-    Next:
-    for (PsiReference reference : ReferencesSearch.search(data.variable, scope)) {
-      PsiElement expression = reference.getElement();
-      while (expression != null) {
-        for (PsiExpression psiExpression : myExpressions.values()) {
-          if (PsiEquivalenceUtil.areElementsEquivalent(expression, psiExpression)) {
-            continue Next;
-          }
-        }
-        expression = PsiTreeUtil.getParentOfType(expression, PsiExpression.class);
-      }
-      return false;
-    }
-    final PsiExpression psiExpression = myExpressions.get(data.variable);
-    if (psiExpression == null) return true;
-    for (PsiVariable variable : myExpressions.keySet()) {
-      if (variable != data.variable && !myDeleted.contains(variable)) {
-        final PsiExpression expr = myExpressions.get(variable);
-        if (expr != null && PsiEquivalenceUtil.areElementsEquivalent(expr, psiExpression)) {
-          myDeleted.add(data.variable);
-          return true;
-        }
-      }
-    }
-    return false;
-  }
-
-  public void foldParameterUsagesInBody(@NotNull ParameterTablePanel.VariableData data, PsiElement[] elements, SearchScope scope) {
-    if (myDeleted.contains(data.variable)) return;
-    final PsiExpression psiExpression = myExpressions.get(data.variable);
-    if (psiExpression == null) return;
-    final Set<PsiExpression> eqExpressions = new HashSet<PsiExpression>();
-    for (PsiReference reference : ReferencesSearch.search(data.variable, scope)) {
-      final PsiExpression expression = findEquivalent(psiExpression, reference.getElement());
-      if (expression != null && expression.isValid()) {
-        eqExpressions.add(expression);
-      }
-    }
-
-    for (PsiExpression expression : eqExpressions) {
-      final PsiExpression refExpression =
-        JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(data.variable.getName(), expression);
-      final PsiElement replaced = expression.replace(refExpression);
-      for (int i = 0, psiElementsLength = elements.length; i < psiElementsLength; i++) {
-        PsiElement psiElement = elements[i];
-        if (expression == psiElement) {
-          elements[i] = replaced;
-          break;
-        }
-      }
-    }
-  }
-
-  public boolean isParameterFoldable(@NotNull ParameterTablePanel.VariableData data,
-                                     @NotNull LocalSearchScope scope,
-                                     @NotNull final List<? extends PsiVariable> inputVariables) {
-    final List<PsiExpression> mentionedInExpressions = getMentionedExpressions(data.variable, scope, inputVariables);
-    if (mentionedInExpressions == null) return false;
-
-    int currentRank = 0;
-    PsiExpression mostRanked = null;
-    for (int i = mentionedInExpressions.size() - 1; i >= 0; i--) {
-      PsiExpression expression = mentionedInExpressions.get(i);
-      if (expression instanceof PsiArrayAccessExpression) {
-        mostRanked = expression;
-        if (!isConditional(expression, scope)) {
-          myFoldingSelectedByDefault = true;
-          break;
-        }
-      }
-      final int r = findUsedVariables(data, inputVariables, expression).size();
-      if (currentRank < r) {
-        currentRank = r;
-        mostRanked = expression;
-      }
-    }
-
-    if (mostRanked != null) {
-      myExpressions.put(data.variable, mostRanked);
-      data.type = mostRanked.getType();
-      final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(mostRanked.getProject());
-      final SuggestedNameInfo nameInfo = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, mostRanked, data.type);
-      if (nameInfo.names.length > 0) {
-        data.name = nameInfo.names[0];
-      }
-      setUniqueName(data);
-    }
-
-    return mostRanked != null;
-  }
-
-  private static boolean isConditional(PsiElement expr, LocalSearchScope scope) {
-    while (expr != null) {
-      final PsiElement parent = expr.getParent();
-      if (parent != null && scope.containsRange(parent.getContainingFile(), parent.getTextRange())) {
-        if (parent instanceof PsiIfStatement) {
-          if (((PsiIfStatement)parent).getCondition() != expr) return true;
-        } else if (parent instanceof PsiConditionalExpression) {
-          if (((PsiConditionalExpression)parent).getCondition() != expr) return true;
-        } else if (parent instanceof PsiSwitchStatement) {
-          if (((PsiSwitchStatement)parent).getExpression() != expr) return true;
-        }
-      } else {
-        return false;
-      }
-      expr = parent;
-    }
-    return false;
-  }
-  
-  private void setUniqueName(ParameterTablePanel.VariableData data) {
-    int idx = 1;
-    while (myUsedNames.contains(data.name)) {
-      data.name += idx;
-    }
-    myUsedNames.add(data.name);
-  }
-
-  private static Set<PsiVariable> findUsedVariables(ParameterTablePanel.VariableData data, final List<? extends PsiVariable> inputVariables,
-                                             PsiExpression expression) {
-    final Set<PsiVariable> found = new HashSet<PsiVariable>();
-    expression.accept(new JavaRecursiveElementVisitor() {
-      @Override
-      public void visitReferenceExpression(PsiReferenceExpression referenceExpression) {
-        super.visitReferenceExpression(referenceExpression);
-        PsiElement resolved = referenceExpression.resolve();
-        if (resolved instanceof PsiVariable && inputVariables.contains(resolved)) {
-          found.add((PsiVariable)resolved);
-        }
-      }
-    });
-    found.remove(data.variable);
-    return found;
-  }
-
-  public boolean isFoldable() {
-    return !myExpressions.isEmpty();
-  }
-
-  @Nullable
-  private List<PsiExpression> getMentionedExpressions(PsiVariable var, LocalSearchScope scope, final List<? extends PsiVariable> inputVariables) {
-    if (myMentionedInExpressions.containsKey(var)) return myMentionedInExpressions.get(var);
-    final PsiElement[] scopeElements = scope.getScope();
-    List<PsiExpression> expressions = null;
-    for (PsiReference reference : ReferencesSearch.search(var, scope)) {
-      PsiElement expression = reference.getElement();
-      if (expressions == null) {
-        expressions = new ArrayList<PsiExpression>();
-        while (expression != null) {
-          if (isAccessedForWriting((PsiExpression)expression)) return null;
-          for (PsiElement scopeElement : scopeElements) {
-            if (PsiTreeUtil.isAncestor(expression, scopeElement, true)) {
-              expression = null;
-              break;
-            }
-          }
-          if (expression == null) break;
-
-          final PsiType expressionType = ((PsiExpression)expression).getType();
-          if (expressionType != null && expressionType != PsiType.VOID && !(expression.getParent() instanceof PsiExpressionStatement)) {
-            if (dependsOnLocals(expression, inputVariables)) {
-              break;
-            }
-            expressions.add((PsiExpression)expression);
-          }
-          expression = PsiTreeUtil.getParentOfType(expression, PsiExpression.class);
-        }
-      }
-      else {
-        for (Iterator<PsiExpression> iterator = expressions.iterator(); iterator.hasNext();) {
-          if (findEquivalent(iterator.next(), expression) == null) {
-            iterator.remove();
-          }
-        }
-      }
-    }
-    myMentionedInExpressions.put(var, expressions);
-    return expressions;
-  }
-
-  private static boolean isAccessedForWriting(PsiExpression expression) {
-    final PsiExpression[] exprWithWriteAccessInside = new PsiExpression[1];
-    expression.accept(new JavaRecursiveElementWalkingVisitor() {
-      @Override
-      public void visitElement(PsiElement element) {
-        if (exprWithWriteAccessInside[0] != null) return;
-        super.visitElement(element);
-      }
-
-      @Override
-      public void visitExpression(PsiExpression expression) {
-        if (PsiUtil.isAccessedForWriting(expression)) {
-          exprWithWriteAccessInside[0] = expression;
-        }
-        super.visitExpression(expression);
-      }
-    });
-    return exprWithWriteAccessInside[0] != null;
-  }
-
-  private static boolean dependsOnLocals(final PsiElement expression, final List<? extends PsiVariable> inputVariables) {
-    final boolean[] localVarsUsed = new boolean[]{false};
-    expression.accept(new JavaRecursiveElementWalkingVisitor(){
-      @Override
-      public void visitReferenceExpression(PsiReferenceExpression expression) {
-        final PsiElement resolved = expression.resolve();
-        if (resolved instanceof PsiVariable) {
-          final PsiVariable variable = (PsiVariable)resolved;
-          if (!inputVariables.contains(variable)) {
-            localVarsUsed[0] = true;
-            return;
-          }
-        }
-        super.visitReferenceExpression(expression);
-      }
-    });
-    return localVarsUsed[0];
-  }
-
-  @NotNull
-  public String getGeneratedCallArgument(@NotNull ParameterTablePanel.VariableData data) {
-    return myExpressions.containsKey(data.variable) ? myExpressions.get(data.variable).getText() : data.variable.getName();
-  }
-
-  public boolean annotateWithParameter(@NotNull ParameterTablePanel.VariableData data, @NotNull PsiElement element) {
-    final PsiExpression psiExpression = myExpressions.get(data.variable);
-    if (psiExpression != null) {
-      final PsiExpression expression = findEquivalent(psiExpression, element);
-      if (expression != null) {
-        expression.putUserData(DuplicatesFinder.PARAMETER, Pair.create(data.variable, expression.getType()));
-        return true;
-      }
-    }
-    return false;
-  }
-
-  @Nullable
-  private static PsiExpression findEquivalent(PsiExpression expr, PsiElement element) {
-    PsiElement expression = element;
-    while (expression  != null) {
-      if (PsiEquivalenceUtil.areElementsEquivalent(expression, expr)) {
-        return (PsiExpression)expression;
-      }
-      expression = PsiTreeUtil.getParentOfType(expression, PsiExpression.class);
-    }
-    return null;
-  }
-
-  public boolean wasExcluded(PsiVariable variable) {
-    return myDeleted.contains(variable) || (myMentionedInExpressions.containsKey(variable) && myExpressions.get(variable) == null);
-  }
-
-  public boolean isFoldingSelectedByDefault() {
-    return myFoldingSelectedByDefault;
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectDialog.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectDialog.java
index b5a9099..2a41db9 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectDialog.java
@@ -27,6 +27,7 @@
 import com.intellij.refactoring.extractMethod.InputVariables;
 import com.intellij.refactoring.ui.ConflictsDialog;
 import com.intellij.refactoring.util.ParameterTablePanel;
+import com.intellij.refactoring.util.VariableData;
 import com.intellij.ui.EditorTextField;
 import com.intellij.util.Function;
 import com.intellij.util.VisibilityUtil;
@@ -78,7 +79,7 @@
   private JPanel myAnonymousClassPanel;
   private JCheckBox myFoldCb;
   private ButtonGroup myVisibilityGroup;
-  private ParameterTablePanel.VariableData[] myInputVariables;
+  private VariableData[] myInputVariables;
 
 
   public ExtractMethodObjectDialog(Project project, PsiClass targetClass, final InputVariables inputVariables, PsiType returnType,
@@ -96,7 +97,7 @@
     myMultipleExitPoints = multipleExitPoints;
 
     boolean canBeVarargs = false;
-    for (ParameterTablePanel.VariableData data : inputVariables.getInputVariables()) {
+    for (VariableData data : inputVariables.getInputVariables()) {
       canBeVarargs |= data.type instanceof PsiArrayType;
     }
     canBeVarargs |= inputVariables.isFoldable()  && inputVariables.isFoldingSelectedByDefault();
@@ -136,7 +137,7 @@
     return myCreateInnerClassRb.isSelected() ? myInnerClassName.getText() : myMethodName.getText();
   }
 
-  public ParameterTablePanel.VariableData[] getChosenParameters() {
+  public VariableData[] getChosenParameters() {
     return myInputVariables;
   }
 
@@ -167,7 +168,7 @@
 
     final JCheckBox makeVarargsCb = myCreateInnerClassRb.isSelected() ? myCbMakeVarargs : myCbMakeVarargsAnonymous;
     if (makeVarargsCb != null && makeVarargsCb.isSelected()) {
-      final ParameterTablePanel.VariableData data = myInputVariables[myInputVariables.length - 1];
+      final VariableData data = myInputVariables[myInputVariables.length - 1];
       if (data.type instanceof PsiArrayType) {
         data.type = new PsiEllipsisType(((PsiArrayType)data.type).getComponentType());
       }
@@ -212,7 +213,7 @@
   protected JComponent createCenterPanel() {
     mySignatureArea.setEditable(false);
     myCreateInnerClassRb.setSelected(true);
-   
+
     final ActionListener enableDisableListener = new ActionListener() {
       public void actionPerformed(final ActionEvent e) {
         enable(myCreateInnerClassRb.isSelected());
@@ -225,11 +226,11 @@
     myFoldCb.setSelected(myVariableData.isFoldingSelectedByDefault());
     myFoldCb.setVisible(myVariableData.isFoldable());
     myVariableData.setFoldingAvailable(myFoldCb.isSelected());
-    myInputVariables = myVariableData.getInputVariables().toArray(new ParameterTablePanel.VariableData[myVariableData.getInputVariables().size()]);
+    myInputVariables = myVariableData.getInputVariables().toArray(new VariableData[myVariableData.getInputVariables().size()]);
     myFoldCb.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent e) {
         myVariableData.setFoldingAvailable(myFoldCb.isSelected());
-        myInputVariables = myVariableData.getInputVariables().toArray(new ParameterTablePanel.VariableData[myVariableData.getInputVariables().size()]);
+        myInputVariables = myVariableData.getInputVariables().toArray(new VariableData[myVariableData.getInputVariables().size()]);
         myParametersTableContainer.removeAll();
         myParametersTableContainer.add(createParametersPanel(), BorderLayout.CENTER);
         updateSignature();
@@ -359,8 +360,8 @@
       buffer.append("\n}.");
       buffer.append(myMethodName.getText());
       buffer.append("(");
-      buffer.append(StringUtil.join(myInputVariables, new Function<ParameterTablePanel.VariableData, String>() {
-        public String fun(final ParameterTablePanel.VariableData variableData) {
+      buffer.append(StringUtil.join(myInputVariables, new Function<VariableData, String>() {
+        public String fun(final VariableData variableData) {
           return variableData.name;
         }
       }, ", "));
@@ -375,7 +376,7 @@
     int count = 0;
     final String indent = "    ";
     for (int i = 0; i < myInputVariables.length; i++) {
-      ParameterTablePanel.VariableData data = myInputVariables[i];
+      VariableData data = myInputVariables[i];
       if (data.passAsParameter) {
         //String typeAndModifiers = PsiFormatUtil.formatVariable(data.variable,
         //  PsiFormatUtil.SHOW_MODIFIERS | PsiFormatUtil.SHOW_TYPE);
diff --git a/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperClassUtil.java b/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperClassUtil.java
index b2509d9..96019d4 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperClassUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperClassUtil.java
@@ -27,10 +27,7 @@
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.MethodSignature;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.PsiUtilBase;
-import com.intellij.psi.util.TypeConversionUtil;
+import com.intellij.psi.util.*;
 import com.intellij.refactoring.memberPullUp.PullUpHelper;
 import com.intellij.refactoring.ui.ConflictsDialog;
 import com.intellij.refactoring.util.DocCommentPolicy;
@@ -76,7 +73,7 @@
     clearPsiReferenceList(subclass.getExtendsList());
 
     // make original class extend extracted superclass
-    PsiJavaCodeReferenceElement ref = createExtendingReference(superclass, subclass, selectedMemberInfos); 
+    PsiJavaCodeReferenceElement ref = createExtendingReference(superclass, subclass, selectedMemberInfos);
     subclass.getExtendsList().add(ref);
 
     PullUpHelper pullUpHelper = new PullUpHelper(subclass, superclass, selectedMemberInfos,
@@ -185,7 +182,7 @@
                                                                                                                            .getName()) !=
                                                                                                                        null;
                                                                                                                    }
-                                                                                                                 }, PsiUtilBase
+                                                                                                                 }, PsiUtilCore
       .toPsiElementArray(movedElements));
     final PsiTypeParameterList originalTypeParameterList = superClass.getTypeParameterList();
     assert originalTypeParameterList != null;
diff --git a/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java b/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java
index 4352e96..4a4e8d8 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java
@@ -22,6 +22,7 @@
 
 import com.intellij.history.LocalHistory;
 import com.intellij.history.LocalHistoryAction;
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.application.ApplicationManager;
@@ -41,7 +42,6 @@
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.refactoring.util.DocCommentPolicy;
 import com.intellij.refactoring.util.classMembers.MemberInfo;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.MultiMap;
@@ -182,7 +182,7 @@
   }
 
   private String getCommandName(final PsiClass subclass, String newName) {
-    return RefactoringBundle.message("extract.superclass.command.name", newName, UsageViewUtil.getDescriptiveName(subclass));
+    return RefactoringBundle.message("extract.superclass.command.name", newName, DescriptiveNameUtil.getDescriptiveName(subclass));
   }
 
   public boolean isEnabledOnElements(PsiElement[] elements) {
diff --git a/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassProcessor.java
index 8aaf941..d096db5 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassProcessor.java
@@ -53,6 +53,7 @@
 import com.intellij.refactoring.util.classMembers.MemberInfo;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
+import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.VisibilityUtil;
 import com.intellij.util.containers.ContainerUtil;
@@ -320,7 +321,7 @@
     super.performRefactoring(usageInfos);
     if (myNewVisibility == null) return;
     for (PsiMember member : members) {
-      VisibilityUtil.fixVisibility(usageInfos, member, myNewVisibility);
+      VisibilityUtil.fixVisibility(UsageViewUtil.toElements(usageInfos), member, myNewVisibility);
     }
   }
 
diff --git a/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationProcessor.java b/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationProcessor.java
index 6d9cc0a..28650c7 100644
--- a/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationProcessor.java
@@ -16,9 +16,11 @@
 package com.intellij.refactoring.inheritanceToDelegation;
 
 import com.intellij.codeInsight.NullableNotNullManager;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.generation.GenerateMembersUtil;
 import com.intellij.codeInsight.generation.OverrideImplementUtil;
 import com.intellij.find.findUsages.PsiElement2UsageTargetAdapter;
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
@@ -37,14 +39,12 @@
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.refactoring.util.ConflictsUtil;
 import com.intellij.refactoring.util.RefactoringUIUtil;
-import com.intellij.refactoring.util.RefactoringUtil;
 import com.intellij.refactoring.util.classMembers.ClassMemberReferencesVisitor;
 import com.intellij.refactoring.util.classRefs.ClassInstanceScanner;
 import com.intellij.refactoring.util.classRefs.ClassReferenceScanner;
 import com.intellij.refactoring.util.classRefs.ClassReferenceSearchingScanner;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.usages.UsageInfoToUsageConverter;
 import com.intellij.usages.UsageTarget;
 import com.intellij.usages.UsageViewManager;
@@ -682,7 +682,7 @@
         }
       }
       final @NonNls String assignmentText = fieldQualifier + myFieldName + "= new " + defaultClassFieldType() + "()";
-      if (statements.length < 1 || !RefactoringUtil.isSuperOrThisCall(statements[0], true, true) || myBaseClass.isInterface()) {
+      if (statements.length < 1 || !JavaHighlightUtil.isSuperOrThisCall(statements[0], true, true) || myBaseClass.isInterface()) {
         PsiExpressionStatement assignmentStatement =
           (PsiExpressionStatement)myFactory.createStatementFromText(
             assignmentText, body
@@ -698,7 +698,7 @@
 
         assignmentStatement = (PsiExpressionStatement)CodeStyleManager.getInstance(myProject).reformat(assignmentStatement);
         if (statements.length > 0) {
-          if (!RefactoringUtil.isSuperOrThisCall(statements[0], true, false)) {
+          if (!JavaHighlightUtil.isSuperOrThisCall(statements[0], true, false)) {
             body.addBefore(assignmentStatement, statements[0]);
           }
           else {
@@ -711,7 +711,7 @@
       }
       else {
         final PsiExpressionStatement callStatement = ((PsiExpressionStatement)statements[0]);
-        if (!RefactoringUtil.isSuperOrThisCall(callStatement, false, true)) {
+        if (!JavaHighlightUtil.isSuperOrThisCall(callStatement, false, true)) {
           final PsiMethodCallExpression superConstructorCall =
             (PsiMethodCallExpression)callStatement.getExpression();
           PsiAssignmentExpression assignmentExpression =
@@ -736,7 +736,7 @@
     PsiMethod[] constructors = myClass.getConstructors();
     for (PsiMethod constructor : constructors) {
       final PsiStatement[] statements = constructor.getBody().getStatements();
-      if (statements.length > 0 && RefactoringUtil.isSuperOrThisCall(statements[0], true, false)) return false;
+      if (statements.length > 0 && JavaHighlightUtil.isSuperOrThisCall(statements[0], true, false)) return false;
     }
     return true;
   }
@@ -749,7 +749,7 @@
       PsiMethod[] constructors = myClass.getConstructors();
       for (PsiMethod constructor : constructors) {
         final PsiStatement[] statements = constructor.getBody().getStatements();
-        if (statements.length > 0 && RefactoringUtil.isSuperOrThisCall(statements[0], true, false)) {
+        if (statements.length > 0 && JavaHighlightUtil.isSuperOrThisCall(statements[0], true, false)) {
           final PsiMethodCallExpression superConstructorCall =
             (PsiMethodCallExpression)((PsiExpressionStatement)statements[0]).getExpression();
           PsiElement superConstructor = superConstructorCall.getMethodExpression().resolve();
@@ -906,7 +906,7 @@
 
 
   protected String getCommandName() {
-    return RefactoringBundle.message("replace.inheritance.with.delegation.command", UsageViewUtil.getDescriptiveName(myClass));
+    return RefactoringBundle.message("replace.inheritance.with.delegation.command", DescriptiveNameUtil.getDescriptiveName(myClass));
   }
 
   private Set<PsiMember> getAllBaseClassMembers() {
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java
index bcf0b35..edb86b4 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.refactoring.inline;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
@@ -30,7 +31,6 @@
 import com.intellij.refactoring.util.*;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.MultiMap;
 import org.jetbrains.annotations.NotNull;
@@ -179,8 +179,8 @@
         } else if (initializer1 instanceof PsiMethodCallExpression) {
           referenceExpression = ((PsiMethodCallExpression)initializer1).getMethodExpression();
         }
-        if (referenceExpression != null && 
-            referenceExpression.getQualifierExpression() == null && 
+        if (referenceExpression != null &&
+            referenceExpression.getQualifierExpression() == null &&
             !(referenceExpression.advancedResolve(false).getCurrentFileResolveScope() instanceof PsiImportStaticStatement)) {
           referenceExpression.setQualifierExpression(qExpression);
         }
@@ -212,7 +212,7 @@
   }
 
   protected String getCommandName() {
-    return RefactoringBundle.message("inline.field.command", UsageViewUtil.getDescriptiveName(myField));
+    return RefactoringBundle.message("inline.field.command", DescriptiveNameUtil.getDescriptiveName(myField));
   }
 
   protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages) {
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
index 344a5f0..3171175 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
@@ -36,7 +36,7 @@
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.PsiUtilCore;
 import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
@@ -104,7 +104,7 @@
               }
               innerClass = parentPsiClass;
               continue;
-            } 
+            }
             innerClassesWithUsages.add(innerClass);
             innerClassUsages.add(element);
           }
@@ -143,7 +143,7 @@
       CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.INLINE_VARIABLE);
       return;
     }
-    final PsiElement[] refsToInline = PsiUtilBase.toPsiElementArray(refsToInlineList);
+    final PsiElement[] refsToInline = PsiUtilCore.toPsiElementArray(refsToInlineList);
 
     EditorColorsManager manager = EditorColorsManager.getInstance();
     final TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
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 7c55aae..1659cac 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
@@ -19,6 +19,7 @@
 import com.intellij.history.LocalHistory;
 import com.intellij.history.LocalHistoryAction;
 import com.intellij.lang.Language;
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.lang.java.JavaLanguage;
 import com.intellij.lang.refactoring.InlineHandler;
 import com.intellij.openapi.diagnostic.Logger;
@@ -51,7 +52,6 @@
 import com.intellij.refactoring.util.*;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.HashMap;
@@ -110,7 +110,7 @@
     myFactory = JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory();
     myCodeStyleManager = CodeStyleManager.getInstance(myProject);
     myJavaCodeStyle = JavaCodeStyleManager.getInstance(myProject);
-    myDescriptiveName = UsageViewUtil.getDescriptiveName(myMethod);
+    myDescriptiveName = DescriptiveNameUtil.getDescriptiveName(myMethod);
   }
 
   protected String getCommandName() {
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 0d1aacf..d186ef9 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java
@@ -54,7 +54,7 @@
 import com.intellij.psi.search.PsiElementProcessor;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.PsiUtilCore;
 import com.intellij.refactoring.IntroduceHandlerBase;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer;
@@ -819,7 +819,7 @@
 
           if (myEditor != null) {
             if (!ApplicationManager.getApplication().isUnitTestMode()) {
-              PsiElement[] exprsToHighlight = PsiUtilBase.toPsiElementArray(array);
+              PsiElement[] exprsToHighlight = PsiUtilCore.toPsiElementArray(array);
               HighlightManager highlightManager = HighlightManager.getInstance(myProject);
               highlightManager.addOccurrenceHighlights(myEditor, exprsToHighlight, highlightAttributes(), true, null);
               WindowManager
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/ElementToWorkOn.java b/java/java-impl/src/com/intellij/refactoring/introduceField/ElementToWorkOn.java
index 93e19e3..9e4f79c 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceField/ElementToWorkOn.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceField/ElementToWorkOn.java
@@ -99,7 +99,7 @@
         }
 
         if (!editor.getSelectionModel().hasSelection()){
-          final List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(file, editor, offset, statementsInRange);
+          final List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(file, editor, offset);
           for (Iterator<PsiExpression> iterator = expressions.iterator(); iterator.hasNext(); ) {
             PsiExpression expression = iterator.next();
             if (!processor.accept(new ElementToWorkOn(null, expression))) {
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java
index 189fe82..8f0f5fb 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java
@@ -25,6 +25,7 @@
 package com.intellij.refactoring.introduceParameter;
 
 import com.intellij.codeInsight.ChangeContextUtil;
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Pair;
@@ -535,7 +536,7 @@
   }
 
   protected String getCommandName() {
-    return RefactoringBundle.message("introduce.parameter.command", UsageViewUtil.getDescriptiveName(myMethodToReplaceIn));
+    return RefactoringBundle.message("introduce.parameter.command", DescriptiveNameUtil.getDescriptiveName(myMethodToReplaceIn));
   }
 
   @Nullable
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
index 3e18ae1..740c2cc 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
@@ -125,7 +125,7 @@
       }
 
       if (!selectionModel.hasSelection()) {
-        final List<PsiExpression> expressions = collectExpressions(file, editor, offset, statementsInRange);
+        final List<PsiExpression> expressions = collectExpressions(file, editor, offset);
         if (expressions.isEmpty()) {
           selectionModel.selectLineAtCaret();
         } else if (expressions.size() == 1) {
@@ -162,7 +162,16 @@
     return Boolean.valueOf(PropertiesComponent.getInstance().getOrInit(PREFER_STATEMENTS_OPTION, "false")).booleanValue() || Registry.is(PREFER_STATEMENTS_OPTION, false);
   }
 
-  public static List<PsiExpression> collectExpressions(final PsiFile file, final Editor editor, final int offset, final PsiElement... statementsInRange) {
+  public static List<PsiExpression> collectExpressions(final PsiFile file,
+                                                       final Editor editor,
+                                                       final int offset) {
+    return collectExpressions(file, editor, offset, false);
+  }
+
+  public static List<PsiExpression> collectExpressions(final PsiFile file,
+                                                       final Editor editor,
+                                                       final int offset,
+                                                       boolean acceptVoid) {
     Document document = editor.getDocument();
     CharSequence text = document.getCharsSequence();
     int correctedOffset = offset;
@@ -196,7 +205,8 @@
     }*/
     PsiExpression expression = PsiTreeUtil.getParentOfType(elementAtCaret, PsiExpression.class);
     while (expression != null) {
-      if (!expressions.contains(expression) && !(expression instanceof PsiParenthesizedExpression) && !(expression instanceof PsiSuperExpression) && expression.getType() != PsiType.VOID) {
+      if (!expressions.contains(expression) && !(expression instanceof PsiParenthesizedExpression) && !(expression instanceof PsiSuperExpression) && 
+          (acceptVoid || expression.getType() != PsiType.VOID)) {
         if (expression instanceof PsiMethodReferenceExpression) {
           expressions.add(expression);
         }
@@ -592,14 +602,14 @@
         final boolean allOccurences = choice != OccurrencesChooser.ReplaceChoice.NO;
         final PsiElement chosenAnchor = allOccurences ? anchorStatementIfAll : anchorStatement;
         final Ref<SmartPsiElementPointer<PsiVariable>> variable = new Ref<SmartPsiElementPointer<PsiVariable>>();
-        
+
         final Editor topLevelEditor;
         if (!InjectedLanguageManager.getInstance(project).isInjectedFragment(anchorStatement.getContainingFile())) {
           topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(editor);
         } else {
           topLevelEditor = editor;
         }
-        
+
         final IntroduceVariableSettings settings =
           getSettings(project, topLevelEditor, expr, occurrences, typeSelectorManager, inFinalContext, hasWriteAccess, validator, chosenAnchor, choice);
         if (!settings.isOK()) {
@@ -840,9 +850,9 @@
             if (!deleteSelf && replaceSelf && expr1 instanceof PsiPolyadicExpression && expr1.isValid() && !expr1.isPhysical() ) {
               array.add(replace(expr1, ref, project));
             }
-            
+
             if (editor != null) {
-              final PsiElement[] replacedOccurences = PsiUtilBase.toPsiElementArray(array);
+              final PsiElement[] replacedOccurences = PsiUtilCore.toPsiElementArray(array);
               highlightReplacedOccurences(project, editor, replacedOccurences);
             }
           } else {
@@ -900,7 +910,7 @@
     }
     return false;
   }
-  
+
   public static PsiExpression replaceExplicitWithDiamondWhenApplicable(final PsiExpression initializer,
                                                                        final PsiType expectedType) {
     if (initializer instanceof PsiNewExpression) {
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java
index 4260c05..7ca675c 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java
@@ -32,6 +32,7 @@
 import com.intellij.refactoring.ui.PackageNameReferenceEditorCombo;
 import com.intellij.refactoring.ui.RefactoringDialog;
 import com.intellij.refactoring.util.ParameterTablePanel;
+import com.intellij.refactoring.util.VariableData;
 import com.intellij.ui.ComboboxWithBrowseButton;
 import com.intellij.ui.DocumentAdapter;
 import com.intellij.ui.RecentsManager;
@@ -53,7 +54,7 @@
 public class IntroduceParameterObjectDialog extends RefactoringDialog {
 
   private final PsiMethod sourceMethod;
-  private final ParameterTablePanel.VariableData[] parameterInfo;
+  private final VariableData[] parameterInfo;
   private JTextField sourceMethodTextField;
 
   private JRadioButton useExistingClassButton;
@@ -94,9 +95,9 @@
     myInnerClassNameTextField.getDocument().addDocumentListener(docListener);
     final PsiParameterList parameterList = sourceMethod.getParameterList();
     final PsiParameter[] parameters = parameterList.getParameters();
-    parameterInfo = new ParameterTablePanel.VariableData[parameters.length];
+    parameterInfo = new VariableData[parameters.length];
     for (int i = 0; i < parameterInfo.length; i++) {
-      parameterInfo[i] = new ParameterTablePanel.VariableData(parameters[i]);
+      parameterInfo[i] = new VariableData(parameters[i]);
       parameterInfo[i].name = parameters[i].getName();
       parameterInfo[i].passAsParameter = true;
     }
@@ -164,8 +165,8 @@
       packageName = getPackageName();
       className = getClassName();
     }
-    List<ParameterTablePanel.VariableData> parameters = new ArrayList<ParameterTablePanel.VariableData>();
-    for (ParameterTablePanel.VariableData data : parameterInfo) {
+    List<VariableData> parameters = new ArrayList<VariableData>();
+    for (VariableData data : parameterInfo) {
       if (data.passAsParameter) {
         parameters.add(data);
       }
@@ -175,7 +176,7 @@
     final MoveDestination moveDestination = ((DestinationFolderComboBox)myDestinationCb)
       .selectDirectory(new PackageWrapper(PsiManager.getInstance(myProject), packageName), false);
     invokeRefactoring(new IntroduceParameterObjectProcessor(className, packageName, moveDestination, sourceMethod,
-                                                            parameters.toArray(new ParameterTablePanel.VariableData[parameters.size()]),
+                                                            parameters.toArray(new VariableData[parameters.size()]),
                                                             keepMethod, useExistingClass,
                                                             createInnerClass, newVisibility, myGenerateAccessorsCheckBox.isSelected()));
   }
@@ -238,7 +239,7 @@
   @NotNull
   public List<PsiParameter> getParametersToExtract() {
     final List<PsiParameter> out = new ArrayList<PsiParameter>();
-    for (ParameterTablePanel.VariableData info : parameterInfo) {
+    for (VariableData info : parameterInfo) {
       if (info.passAsParameter) {
         out.add((PsiParameter)info.variable);
       }
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectProcessor.java b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectProcessor.java
index bcd84bd..5fdf3f7 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectProcessor.java
@@ -26,6 +26,7 @@
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.codeStyle.VariableKind;
+import com.intellij.psi.impl.source.javadoc.PsiDocParamRef;
 import com.intellij.psi.javadoc.PsiDocComment;
 import com.intellij.psi.javadoc.PsiDocTag;
 import com.intellij.psi.search.GlobalSearchScope;
@@ -37,13 +38,10 @@
 import com.intellij.refactoring.MoveDestination;
 import com.intellij.refactoring.RefactorJBundle;
 import com.intellij.refactoring.introduceparameterobject.usageInfo.*;
-import com.intellij.refactoring.psi.PropertyUtils;
-import com.intellij.refactoring.util.FixableUsageInfo;
-import com.intellij.refactoring.util.FixableUsagesRefactoringProcessor;
-import com.intellij.refactoring.util.ParameterTablePanel;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.*;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
+import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.VisibilityUtil;
 import com.intellij.util.containers.MultiMap;
@@ -77,7 +75,7 @@
                                            String packageName,
                                            MoveDestination moveDestination,
                                            PsiMethod method,
-                                           ParameterTablePanel.VariableData[] parameters, boolean keepMethodAsDelegate, final boolean useExistingClass,
+                                           VariableData[] parameters, boolean keepMethodAsDelegate, final boolean useExistingClass,
                                            final boolean createInnerClass,
                                            String newVisibility,
                                            boolean generateAccessors) {
@@ -92,14 +90,14 @@
     myNewVisibility = newVisibility;
     myGenerateAccessors = generateAccessors;
     this.parameters = new ArrayList<ParameterChunk>();
-    for (ParameterTablePanel.VariableData parameter : parameters) {
+    for (VariableData parameter : parameters) {
       this.parameters.add(new ParameterChunk(parameter));
     }
     final PsiParameterList parameterList = method.getParameterList();
     final PsiParameter[] methodParams = parameterList.getParameters();
     paramsToMerge = new int[parameters.length];
     for (int p = 0; p < parameters.length; p++) {
-      ParameterTablePanel.VariableData parameter = parameters[p];
+      VariableData parameter = parameters[p];
       for (int i = 0; i < methodParams.length; i++) {
         final PsiParameter methodParam = methodParams[i];
         if (parameter.variable.equals(methodParam)) {
@@ -119,7 +117,7 @@
         return super.visitClassType(classType);
       }
     };
-    for (ParameterTablePanel.VariableData parameter : parameters) {
+    for (VariableData parameter : parameters) {
       parameter.type.accept(typeParametersVisitor);
     }
     typeParams = new ArrayList<PsiTypeParameter>(typeParamSet);
@@ -266,7 +264,7 @@
     beanClassBuilder.setClassName(className);
     beanClassBuilder.setPackageName(packageName);
     for (ParameterChunk parameterChunk : parameters) {
-      final ParameterTablePanel.VariableData parameter = parameterChunk.parameter;
+      final VariableData parameter = parameterChunk.parameter;
       final boolean setterRequired = paramsNeedingSetters.contains(parameter.variable);
       beanClassBuilder.addField((PsiParameter)parameter.variable,  parameter.name, parameter.type, setterRequired);
     }
@@ -316,6 +314,16 @@
       for (PsiDocTag paramTag : paramTags) {
         final PsiElement[] dataElements = paramTag.getDataElements();
         if (dataElements.length > 0) {
+          if (dataElements[0] instanceof PsiDocParamRef) {
+            final PsiReference reference = dataElements[0].getReference();
+            if (reference != null) {
+              final PsiElement resolve = reference.resolve();
+              if (resolve instanceof PsiParameter) {
+                final int parameterIndex = method.getParameterList().getParameterIndex((PsiParameter)resolve);
+                if (ArrayUtil.find(paramsToMerge, parameterIndex) < 0) continue;
+              }
+            }
+          }
           mergedTags.add((PsiDocTag)paramTag.copy());
         }
       }
@@ -411,12 +419,12 @@
 
       parameterChunk.setField(field);
 
-      final PsiMethod getterForField = PropertyUtils.findGetterForField(field);
+      final PsiMethod getterForField = PropertyUtil.findGetterForField(field);
       if (getterForField != null) {
         parameterChunk.setGetter(getterForField.getName());
       }
 
-      final PsiMethod setterForField = PropertyUtils.findSetterForField(field);
+      final PsiMethod setterForField = PropertyUtil.findSetterForField(field);
       if (setterForField != null) {
         parameterChunk.setSetter(setterForField.getName());
       }
@@ -439,12 +447,12 @@
   }
 
   public static class ParameterChunk {
-    private final ParameterTablePanel.VariableData parameter;
+    private final VariableData parameter;
     private PsiField field;
     private String getter;
     private String setter;
 
-    public ParameterChunk(ParameterTablePanel.VariableData parameter) {
+    public ParameterChunk(VariableData parameter) {
       this.parameter = parameter;
     }
 
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/usageInfo/BeanClassVisibilityUsageInfo.java b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/usageInfo/BeanClassVisibilityUsageInfo.java
index 3161380..fab0644 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/usageInfo/BeanClassVisibilityUsageInfo.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/usageInfo/BeanClassVisibilityUsageInfo.java
@@ -24,6 +24,7 @@
 import com.intellij.psi.PsiMethod;
 import com.intellij.refactoring.util.FixableUsageInfo;
 import com.intellij.usageView.UsageInfo;
+import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.VisibilityUtil;
 
@@ -46,9 +47,9 @@
 
   @Override
   public void fixUsage() throws IncorrectOperationException {
-    VisibilityUtil.fixVisibility(usages, existingClass, myNewVisibility);
+    VisibilityUtil.fixVisibility(UsageViewUtil.toElements(usages), existingClass, myNewVisibility);
     if (myExistingClassCompatibleConstructor != null) {
-      VisibilityUtil.fixVisibility(usages, myExistingClassCompatibleConstructor, myNewVisibility);
+      VisibilityUtil.fixVisibility(UsageViewUtil.toElements(usages), myExistingClassCompatibleConstructor, myNewVisibility);
     }
   }
 }
diff --git a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanDialog.java b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanDialog.java
index c230a87..4870241 100644
--- a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanDialog.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.refactoring.invertBoolean;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.help.HelpManager;
 import com.intellij.psi.PsiNamedElement;
@@ -47,7 +48,7 @@
     myLabel.setText(RefactoringBundle.message("invert.boolean.name.of.inverted.element", typeString));
     myCaptionLabel.setText(RefactoringBundle.message("invert.0.1",
                                                      typeString,
-                                                     UsageViewUtil.getDescriptiveName(myElement)));
+                                                     DescriptiveNameUtil.getDescriptiveName(myElement)));
 
     setTitle(InvertBooleanHandler.REFACTORING_NAME);
     init();
diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/AbstractMakeStaticDialog.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/AbstractMakeStaticDialog.java
index e76ad57..a990681 100644
--- a/java/java-impl/src/com/intellij/refactoring/makeStatic/AbstractMakeStaticDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/AbstractMakeStaticDialog.java
@@ -19,7 +19,7 @@
  * User: dsl
  * Date: 04.07.2002
  * Time: 13:14:49
- * To change template for new class use 
+ * To change template for new class use
  * Code Style | Class Templates options (Tools | IDE Options).
  */
 package com.intellij.refactoring.makeStatic;
@@ -30,7 +30,7 @@
 import com.intellij.psi.PsiTypeParameterListOwner;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.ui.RefactoringDialog;
-import com.intellij.refactoring.util.ParameterTablePanel;
+import com.intellij.refactoring.util.VariableData;
 import com.intellij.usageView.UsageViewUtil;
 
 import javax.swing.*;
@@ -68,7 +68,7 @@
 
   public abstract String getClassParameterName();
 
-  public abstract ParameterTablePanel.VariableData[] getVariableData();
+  public abstract VariableData[] getVariableData();
 
   public abstract boolean isReplaceUsages();
 
diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodOrClassStaticProcessor.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodOrClassStaticProcessor.java
index ac618d8..2e6467b 100644
--- a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodOrClassStaticProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodOrClassStaticProcessor.java
@@ -24,6 +24,7 @@
  */
 package com.intellij.refactoring.makeStatic;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
@@ -274,7 +275,7 @@
   }
 
   protected String getCommandName() {
-    return RefactoringBundle.message("make.static.command", UsageViewUtil.getDescriptiveName(myMember));
+    return RefactoringBundle.message("make.static.command", DescriptiveNameUtil.getDescriptiveName(myMember));
   }
 
   public T getMember() {
diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeParameterizedStaticDialog.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeParameterizedStaticDialog.java
index c737e10..40e1d5e 100644
--- a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeParameterizedStaticDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeParameterizedStaticDialog.java
@@ -24,6 +24,7 @@
  */
 package com.intellij.refactoring.makeStatic;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.help.HelpManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.ComboBox;
@@ -33,8 +34,8 @@
 import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.util.ParameterTablePanel;
+import com.intellij.refactoring.util.VariableData;
 import com.intellij.ui.DocumentAdapter;
-import com.intellij.ui.IdeBorderFactory;
 import com.intellij.usageView.UsageViewUtil;
 
 import javax.swing.*;
@@ -52,7 +53,7 @@
   private final JCheckBox myMakeFieldParameters = new JCheckBox();
 
   private ParameterTablePanel myParameterPanel;
-  private ParameterTablePanel.VariableData[] myVariableData;
+  private VariableData[] myVariableData;
   private final boolean myAnyNonFieldMembersUsed;
 
 
@@ -71,10 +72,10 @@
   }
 
   private boolean buildVariableData(InternalUsageInfo[] internalUsages) {
-    ArrayList<ParameterTablePanel.VariableData> variableDatum = new ArrayList<ParameterTablePanel.VariableData>();
+    ArrayList<VariableData> variableDatum = new ArrayList<VariableData>();
     boolean nonFieldUsages = MakeStaticUtil.collectVariableData(myMember, internalUsages, variableDatum);
 
-    myVariableData = variableDatum.toArray(new ParameterTablePanel.VariableData[0]);
+    myVariableData = variableDatum.toArray(new VariableData[0]);
     return nonFieldUsages;
   }
 
@@ -109,7 +110,7 @@
    *
    * @return null if field parameters are not selected
    */
-  public ParameterTablePanel.VariableData[] getVariableData() {
+  public VariableData[] getVariableData() {
     if(myMakeFieldParameters != null && myMakeFieldParameters.isSelected()) {
       return myVariableData;
     }
@@ -222,7 +223,8 @@
     if (isMakeClassParameter()) {
       final PsiMethod methodWithParameter = checkParameterDoesNotExist();
       if (methodWithParameter != null) {
-        String who = methodWithParameter == myMember ? RefactoringBundle.message("this.method") : UsageViewUtil.getDescriptiveName(methodWithParameter);
+        String who = methodWithParameter == myMember ? RefactoringBundle.message("this.method") : DescriptiveNameUtil
+          .getDescriptiveName(methodWithParameter);
         String message = RefactoringBundle.message("0.already.has.parameter.named.1.use.this.name.anyway", who, getClassParameterName());
         ret = Messages.showYesNoDialog(myProject, message, RefactoringBundle.message("warning.title"), Messages.getWarningIcon());
         myClassParameterNameInputField.requestFocusInWindow();
diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeStaticUtil.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeStaticUtil.java
index c1e2269..e5c966f 100644
--- a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeStaticUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeStaticUtil.java
@@ -29,8 +29,8 @@
 import com.intellij.psi.codeStyle.VariableKind;
 import com.intellij.psi.util.InheritanceUtil;
 import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.refactoring.util.ParameterTablePanel;
 import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.VariableData;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -132,13 +132,13 @@
     return false;
   }
 
-  public static boolean buildVariableData(PsiTypeParameterListOwner member, ArrayList<ParameterTablePanel.VariableData> result) {
+  public static boolean buildVariableData(PsiTypeParameterListOwner member, ArrayList<VariableData> result) {
     final InternalUsageInfo[] classRefsInMethod = findClassRefsInMember(member, false);
     return collectVariableData(member, classRefsInMethod, result);
   }
 
   public static boolean collectVariableData(PsiMember member, InternalUsageInfo[] internalUsages,
-                                             ArrayList<ParameterTablePanel.VariableData> variableDatum) {
+                                             ArrayList<VariableData> variableDatum) {
     HashSet<PsiField> reported = new HashSet<PsiField>();
     HashSet<PsiField> accessedForWriting = new HashSet<PsiField>();
     boolean needClassParameter = false;
@@ -165,7 +165,7 @@
     });
     for (final PsiField field : psiFields) {
       if (accessedForWriting.contains(field)) continue;
-      ParameterTablePanel.VariableData data = new ParameterTablePanel.VariableData(field);
+      VariableData data = new VariableData(field);
       JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(member.getProject());
       String name = field.getName();
       name = codeStyleManager.variableNameToPropertyName(name, VariableKind.FIELD);
diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/Settings.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/Settings.java
index e3bdccf..cd76eb9 100644
--- a/java/java-impl/src/com/intellij/refactoring/makeStatic/Settings.java
+++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/Settings.java
@@ -19,14 +19,14 @@
  * User: dsl
  * Date: 01.07.2002
  * Time: 15:48:33
- * To change template for new class use 
+ * To change template for new class use
  * Code Style | Class Templates options (Tools | IDE Options).
  */
 package com.intellij.refactoring.makeStatic;
 
 import com.intellij.psi.PsiField;
 import com.intellij.psi.PsiType;
-import com.intellij.refactoring.util.ParameterTablePanel;
+import com.intellij.refactoring.util.VariableData;
 import com.intellij.util.containers.HashMap;
 import org.jetbrains.annotations.Nullable;
 
@@ -56,7 +56,7 @@
 
 
   public Settings(boolean replaceUsages, String classParameterName,
-                  ParameterTablePanel.VariableData[] variableDatum) {
+                  VariableData[] variableDatum) {
     myReplaceUsages = replaceUsages;
     myMakeClassParameter = classParameterName != null;
     myClassParameterName = classParameterName;
@@ -64,7 +64,7 @@
     myFieldToNameList = new ArrayList<FieldParameter>();
     if(myMakeFieldParameters) {
       myFieldToNameMapping = new com.intellij.util.containers.HashMap<PsiField, String>();
-      for (ParameterTablePanel.VariableData data : variableDatum) {
+      for (VariableData data : variableDatum) {
         if (data.passAsParameter) {
           myFieldToNameMapping.put((PsiField)data.variable, data.name);
           myFieldToNameList.add(new FieldParameter((PsiField)data.variable, data.name, data.type));
@@ -76,7 +76,7 @@
     }
   }
 
-  public Settings(boolean replaceUsages, String classParameterName, 
+  public Settings(boolean replaceUsages, String classParameterName,
                   PsiField[] fields, String[] names) {
     myReplaceUsages = replaceUsages;
     myMakeClassParameter = classParameterName != null;
@@ -96,7 +96,7 @@
       myFieldToNameMapping = null;
     }
   }
-  
+
   public boolean isReplaceUsages() {
     return myReplaceUsages;
   }
diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/SimpleMakeStaticDialog.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/SimpleMakeStaticDialog.java
index 995255a..3bbc129 100644
--- a/java/java-impl/src/com/intellij/refactoring/makeStatic/SimpleMakeStaticDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/SimpleMakeStaticDialog.java
@@ -19,7 +19,7 @@
  * User: dsl
  * Date: 04.07.2002
  * Time: 13:54:39
- * To change template for new class use 
+ * To change template for new class use
  * Code Style | Class Templates options (Tools | IDE Options).
  */
 package com.intellij.refactoring.makeStatic;
@@ -30,8 +30,7 @@
 import com.intellij.psi.PsiTypeParameterListOwner;
 import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.RefactoringBundle;
-import com.intellij.refactoring.util.ParameterTablePanel;
-import com.intellij.ui.IdeBorderFactory;
+import com.intellij.refactoring.util.VariableData;
 import com.intellij.usageView.UsageViewUtil;
 
 import javax.swing.*;
@@ -59,7 +58,7 @@
     return null;
   }
 
-  public ParameterTablePanel.VariableData[] getVariableData() {
+  public VariableData[] getVariableData() {
     return null;
   }
 
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 0f7b115..95c826f 100644
--- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java
+++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java
@@ -29,6 +29,7 @@
 import com.intellij.codeInsight.ChangeContextUtil;
 import com.intellij.codeInsight.PsiEquivalenceUtil;
 import com.intellij.codeInsight.intention.AddAnnotationFix;
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.diagnostic.Logger;
@@ -54,7 +55,6 @@
 import com.intellij.refactoring.util.duplicates.MethodDuplicatesHandler;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.Query;
 import com.intellij.util.VisibilityUtil;
@@ -154,7 +154,7 @@
   }
 
   protected String getCommandName() {
-    return RefactoringBundle.message("pullUp.command", UsageViewUtil.getDescriptiveName(mySourceClass));
+    return RefactoringBundle.message("pullUp.command", DescriptiveNameUtil.getDescriptiveName(mySourceClass));
   }
 
   public void moveMembersToBase() throws IncorrectOperationException {
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassToInnerProcessor.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassToInnerProcessor.java
index ca3ecc3..48ab4c4 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassToInnerProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassToInnerProcessor.java
@@ -24,10 +24,7 @@
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.psi.util.PsiElementFilter;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.*;
 import com.intellij.refactoring.BaseRefactoringProcessor;
 import com.intellij.refactoring.PackageWrapper;
 import com.intellij.refactoring.RefactoringBundle;
@@ -186,7 +183,7 @@
         elementsToMakeWritable.add(element);
       }
     }
-    if (!CommonRefactoringUtil.checkReadOnlyStatus(myProject, PsiUtilBase.toPsiElementArray(elementsToMakeWritable))) {
+    if (!CommonRefactoringUtil.checkReadOnlyStatus(myProject, PsiUtilCore.toPsiElementArray(elementsToMakeWritable))) {
       return false;
     }
     return true;
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java
index 83851b3..e94e32e 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java
@@ -25,6 +25,7 @@
 import com.intellij.openapi.help.HelpManager;
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.Pass;
@@ -32,6 +33,8 @@
 import com.intellij.psi.*;
 import com.intellij.psi.search.ProjectScope;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.PsiUtilCore;
 import com.intellij.refactoring.*;
 import com.intellij.refactoring.move.MoveCallback;
 import com.intellij.refactoring.move.MoveClassesOrPackagesCallback;
@@ -47,6 +50,7 @@
 import com.intellij.ui.ReferenceEditorWithBrowseButton;
 import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.containers.hash.HashSet;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -56,6 +60,7 @@
 import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.util.Set;
 
 public class MoveClassesOrPackagesDialog extends RefactoringDialog {
   @NonNls private static final String RECENTS_KEY = "MoveClassesOrPackagesDialog.RECENTS_KEY";
@@ -270,7 +275,12 @@
 
     if (initialTargetDirectory != null && 
         JavaMoveClassesOrPackagesHandler.packageHasMultipleDirectoriesInModule(myProject, initialTargetDirectory)) {
-      initialTargetDirectory = null;
+      final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
+      final Set<VirtualFile> initialRoots = new HashSet<VirtualFile>();
+      collectSourceRoots(psiElements, fileIndex, initialRoots);
+      if (initialRoots.size() > 1) {
+        initialTargetDirectory = null;
+      }
     }
     ((DestinationFolderComboBox)myDestinationFolderCB).setData(myProject, initialTargetDirectory,
                                                                new Pass<String>() {
@@ -284,6 +294,20 @@
     myHelpID = helpID;
   }
 
+  private static void collectSourceRoots(PsiElement[] psiElements, ProjectFileIndex fileIndex, Set<VirtualFile> initialRoots) {
+    for (PsiElement element : psiElements) {
+      final VirtualFile file = PsiUtilCore.getVirtualFile(element);
+      if (file != null) {
+        final VirtualFile sourceRootForFile = fileIndex.getSourceRootForFile(file);
+        if (sourceRootForFile != null) {
+          initialRoots.add(sourceRootForFile);
+        }
+      } else if (element instanceof PsiDirectoryContainer) {
+        collectSourceRoots(((PsiDirectoryContainer)element).getDirectories(), fileIndex, initialRoots);
+      }
+    }
+  }
+
   protected void doHelpAction() {
     HelpManager.getInstance().invokeHelp(myHelpID);
   }
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesUtil.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesUtil.java
index f487e94..2982483 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesUtil.java
@@ -275,14 +275,15 @@
 
     PsiDirectory[] directories = aPackage != null ? aPackage.getDirectories() : null;
     final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
-    final boolean filterOutSources = baseDir != null && fileIndex.isInTestSourceContent(baseDir.getVirtualFile());
-    if (directories != null && directories.length == 1 && !(filterOutSources &&
-                                                            !fileIndex.isInTestSourceContent(directories[0].getVirtualFile()))) {
+    final VirtualFile baseDirVirtualFile = baseDir != null ? baseDir.getVirtualFile() : null;
+    final boolean isBaseDirInTestSources = baseDirVirtualFile != null && fileIndex.isInTestSourceContent(baseDirVirtualFile);
+    if (directories != null && directories.length == 1 && (baseDirVirtualFile == null ||
+                                                           fileIndex.isInTestSourceContent(directories[0].getVirtualFile()) == isBaseDirInTestSources)) {
       directory = directories[0];
     }
     else {
       final VirtualFile[] contentSourceRoots = ProjectRootManager.getInstance(project).getContentSourceRoots();
-      if (contentSourceRoots.length == 1 && !(filterOutSources && !fileIndex.isInTestSourceContent(contentSourceRoots[0]))) {
+      if (contentSourceRoots.length == 1 && (baseDirVirtualFile == null || fileIndex.isInTestSourceContent(contentSourceRoots[0]) == isBaseDirInTestSources)) {
         directory = ApplicationManager.getApplication().runWriteAction(new Computable<PsiDirectory>() {
           @Override
           public PsiDirectory compute() {
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/JavaMoveFilesOrDirectoriesHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/JavaMoveFilesOrDirectoriesHandler.java
index c67b7b7..0f64675 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/JavaMoveFilesOrDirectoriesHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/JavaMoveFilesOrDirectoriesHandler.java
@@ -25,7 +25,7 @@
 import com.intellij.psi.impl.file.JavaDirectoryServiceImpl;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.PsiUtilCore;
 import com.intellij.refactoring.move.MoveCallback;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.Function;
@@ -63,7 +63,7 @@
     for (PsiElement sourceElement : sourceElements) {
       result.add(sourceElement instanceof PsiClass ? sourceElement.getContainingFile() : sourceElement);
     }
-    return PsiUtilBase.toPsiElementArray(result);
+    return PsiUtilCore.toPsiElementArray(result);
   }
 
   @Override
@@ -91,7 +91,7 @@
                   adjustedElements.add(element);
                 }
               }
-              result.setResult(PsiUtilBase.toPsiElementArray(adjustedElements));
+              result.setResult(PsiUtilCore.toPsiElementArray(adjustedElements));
             }
           }.execute().getResultObject();
         }
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 57936c6..35ca3e2 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
@@ -16,7 +16,8 @@
 package com.intellij.refactoring.move.moveInner;
 
 import com.intellij.codeInsight.ChangeContextUtil;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.fileEditor.FileEditorManager;
 import com.intellij.openapi.fileEditor.OpenFileDescriptor;
@@ -39,7 +40,6 @@
 import com.intellij.refactoring.util.*;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.VisibilityUtil;
@@ -171,7 +171,7 @@
 
       ChangeContextUtil.encodeContextInfo(myInnerClass, false);
 
-      myInnerClass = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(myInnerClass);
+      myInnerClass = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(myInnerClass);
 
       final MoveInnerOptions moveInnerOptions = new MoveInnerOptions(myInnerClass, myOuterClass, myTargetContainer, myNewClassName);
       final MoveInnerHandler handler = MoveInnerHandler.EP_NAME.forLanguage(myInnerClass.getLanguage());
@@ -407,7 +407,7 @@
                     @NotNull final PsiElement targetContainer) {
     myNewClassName = className;
     myInnerClass = innerClass;
-    myDescriptiveName = UsageViewUtil.getDescriptiveName(myInnerClass);
+    myDescriptiveName = DescriptiveNameUtil.getDescriptiveName(myInnerClass);
     myOuterClass = myInnerClass.getContainingClass();
     myTargetContainer = targetContainer;
     JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(myProject);
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInstanceMethod/MoveInstanceMethodDialogBase.java b/java/java-impl/src/com/intellij/refactoring/move/moveInstanceMethod/MoveInstanceMethodDialogBase.java
index 67a1c98..1196d73 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInstanceMethod/MoveInstanceMethodDialogBase.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInstanceMethod/MoveInstanceMethodDialogBase.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.refactoring.move.moveInstanceMethod;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.psi.PsiClass;
@@ -28,7 +29,6 @@
 import com.intellij.refactoring.ui.RefactoringDialog;
 import com.intellij.ui.ScrollPaneFactory;
 import com.intellij.ui.components.JBList;
-import com.intellij.usageView.UsageViewUtil;
 
 import javax.swing.*;
 import javax.swing.event.ListSelectionEvent;
@@ -109,14 +109,15 @@
     if (targetClass.isInterface()) {
       final Project project = getProject();
       if (ClassInheritorsSearch.search(targetClass, false).findFirst() == null) {
-        final String message = RefactoringBundle.message("0.is.an.interface.that.has.no.implementing.classes", UsageViewUtil.getDescriptiveName(targetClass));
+        final String message = RefactoringBundle.message("0.is.an.interface.that.has.no.implementing.classes", DescriptiveNameUtil
+          .getDescriptiveName(targetClass));
 
         Messages.showErrorDialog(project, message, myRefactoringName);
         return false;
       }
 
       final String message = RefactoringBundle.message("0.is.an.interface.method.implementation.will.be.added.to.all.directly.implementing.classes",
-                                                       UsageViewUtil.getDescriptiveName(targetClass));
+                                                       DescriptiveNameUtil.getDescriptiveName(targetClass));
 
       final int result = Messages.showYesNoDialog(project, message, myRefactoringName,
                                                   Messages.getQuestionIcon());
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 5784665..ca844f0 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
@@ -34,6 +34,7 @@
 import com.intellij.refactoring.util.*;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
+import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.VisibilityUtil;
 import com.intellij.util.containers.HashSet;
@@ -245,7 +246,7 @@
       for (PsiReference reference : docRefs) {
         reference.bindToElement(method);
       }
-      VisibilityUtil.fixVisibility(usages, method, myNewVisibility);
+      VisibilityUtil.fixVisibility(UsageViewUtil.toElements(usages), method, myNewVisibility);
     }
     catch (IncorrectOperationException e) {
       LOG.error(e);
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java
index 4efd85f..3f4f59a 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java
@@ -22,7 +22,7 @@
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.PsiUtilCore;
 import com.intellij.refactoring.BaseRefactoringProcessor;
 import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.RefactoringBundle;
@@ -105,7 +105,7 @@
 
   @NotNull
   protected UsageViewDescriptor createUsageViewDescriptor(UsageInfo[] usages) {
-    return new MoveMemberViewDescriptor(PsiUtilBase.toPsiElementArray(myMembersToMove));
+    return new MoveMemberViewDescriptor(PsiUtilCore.toPsiElementArray(myMembersToMove));
   }
 
   @NotNull
@@ -203,7 +203,7 @@
           final PsiElement anchor;
           if (anchorsInSourceClass.containsKey(member)) {
             final PsiMember memberInSourceClass = anchorsInSourceClass.get(member);
-            //anchor should be already moved as myMembersToMove contains members in order they appear in source class 
+            //anchor should be already moved as myMembersToMove contains members in order they appear in source class
             anchor = memberInSourceClass != null ? movedMembers.get(memberInSourceClass) : null;
           }
           else {
@@ -258,7 +258,8 @@
         filtered.add(usage);
       }
     }
-    VisibilityUtil.fixVisibility(filtered.toArray(new UsageInfo[filtered.size()]), newMember, myNewVisibility);
+    UsageInfo[] infos = filtered.toArray(new UsageInfo[filtered.size()]);
+    VisibilityUtil.fixVisibility(UsageViewUtil.toElements(infos), newMember, myNewVisibility);
   }
 
   protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages) {
diff --git a/java/java-impl/src/com/intellij/refactoring/psi/PropertyUtils.java b/java/java-impl/src/com/intellij/refactoring/psi/PropertyUtils.java
deleted file mode 100644
index 9d188b7..0000000
--- a/java/java-impl/src/com/intellij/refactoring/psi/PropertyUtils.java
+++ /dev/null
@@ -1,281 +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.refactoring.psi;
-
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.psi.util.PropertyUtil;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class PropertyUtils {
-    private PropertyUtils() {
-    }
-
-    public static PsiMethod findSetterForField(PsiField field) {
-        final PsiClass containingClass = field.getContainingClass();
-        final Project project = field.getProject();
-        final String propertyName = PropertyUtil.suggestPropertyName(project, field);
-        final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
-        return PropertyUtil.findPropertySetter(containingClass, propertyName, isStatic, true);
-    }
-
-    public static PsiMethod findGetterForField(PsiField field) {
-        final PsiClass containingClass = field.getContainingClass();
-        final Project project = field.getProject();
-        final String propertyName = PropertyUtil.suggestPropertyName(project, field);
-        final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
-        return PropertyUtil.findPropertyGetter(containingClass, propertyName, isStatic, true);
-    }
-
-  /**
-   * If the name of the method looks like a getter and the body consists of a single return statement,
-   * returns the returned expression. Otherwise, returns null.
-   *
-   * @param method the method to check
-   * @return the return value, or null if it doesn't match the condotions.
-   */
-  @Nullable
-  public static PsiExpression getGetterReturnExpression(PsiMethod method) {
-    return method != null && hasGetterSignature(method) ? getSingleReturnValue(method) : null;
-  }
-
-  private static boolean hasGetterSignature(@NotNull PsiMethod method) {
-    return PropertyUtil.isSimplePropertyGetter(method) && !method.hasModifierProperty(PsiModifier.SYNCHRONIZED);
-  }
-
-  @Nullable
-  public static PsiExpression getSingleReturnValue(@NotNull PsiMethod method) {
-    final PsiCodeBlock body = method.getBody();
-    if (body == null) {
-      return null;
-    }
-    final PsiStatement[] statements = body.getStatements();
-    final PsiStatement statement = statements.length != 1 ? null : statements[0];
-    return statement instanceof PsiReturnStatement ? ((PsiReturnStatement)statement).getReturnValue() : null;
-  }
-
-  @Nullable
-  public static PsiField getFieldOfGetter(PsiMethod method) {
-    PsiField field = getSimplyReturnedField(method, getGetterReturnExpression(method));
-    if (field != null) {
-      final PsiType returnType = method.getReturnType();
-      if (returnType != null && field.getType().equalsToText(returnType.getCanonicalText())) {
-        return field;
-      }
-    }
-    return null;
-  }
-
-  @Nullable
-  public static PsiField getSimplyReturnedField(PsiMethod method, @Nullable PsiExpression value) {
-    if (!(value instanceof PsiReferenceExpression)) {
-      return null;
-    }
-
-    final PsiReferenceExpression reference = (PsiReferenceExpression)value;
-    if (hasSubstantialQualifier(reference)) {
-      return null;
-    }
-
-    final PsiElement referent = reference.resolve();
-    if (!(referent instanceof PsiField)) {
-      return null;
-    }
-
-    final PsiField field = (PsiField)referent;
-    return InheritanceUtil.isInheritorOrSelf(method.getContainingClass(), field.getContainingClass(), true) ? field : null;
-  }
-
-  private static boolean hasSubstantialQualifier(PsiReferenceExpression reference) {
-    final PsiExpression qualifier = reference.getQualifierExpression();
-    if (qualifier == null) return false;
-
-    if (qualifier instanceof PsiThisExpression || qualifier instanceof PsiSuperExpression) {
-      return false;
-    }
-
-    if (qualifier instanceof PsiReferenceExpression) {
-      return !(((PsiReferenceExpression)qualifier).resolve() instanceof PsiClass);
-    }
-    return true;
-  }
-
-  public static boolean isSimpleGetter(PsiMethod method) {
-    return getFieldOfGetter(method) != null;
-  }
-
-  @Nullable
-  public static PsiField getFieldOfSetter(PsiMethod method) {
-    if (method == null) {
-      return null;
-    }
-    final PsiParameterList parameterList = method.getParameterList();
-    if (parameterList.getParametersCount() != 1) {
-      return null;
-    }
-    @NonNls final String name = method.getName();
-    if (!name.startsWith("set")) {
-      return null;
-    }
-    if (method.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
-      return null;
-    }
-    final PsiCodeBlock body = method.getBody();
-    if (body == null) {
-      return null;
-    }
-    final PsiStatement[] statements = body.getStatements();
-    if (statements.length != 1) {
-      return null;
-    }
-    final PsiStatement statement = statements[0];
-    if (!(statement instanceof PsiExpressionStatement)) {
-      return null;
-    }
-    final PsiExpressionStatement possibleAssignmentStatement = (PsiExpressionStatement)statement;
-    final PsiExpression possibleAssignment = possibleAssignmentStatement.getExpression();
-    if (!(possibleAssignment instanceof PsiAssignmentExpression)) {
-      return null;
-    }
-    final PsiAssignmentExpression assignment = (PsiAssignmentExpression)possibleAssignment;
-    if (!JavaTokenType.EQ.equals(assignment.getOperationTokenType())) {
-      return null;
-    }
-    final PsiExpression lhs = assignment.getLExpression();
-    if (!(lhs instanceof PsiReferenceExpression)) {
-      return null;
-    }
-    final PsiReferenceExpression reference = (PsiReferenceExpression)lhs;
-    final PsiExpression qualifier = reference.getQualifierExpression();
-    if (qualifier instanceof PsiReferenceExpression) {
-      final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)qualifier;
-      final PsiElement target = referenceExpression.resolve();
-      if (!(target instanceof PsiClass)) {
-        return null;
-      }
-    }
-    else if (qualifier != null && !(qualifier instanceof PsiThisExpression) && !(qualifier instanceof PsiSuperExpression)) {
-      return null;
-    }
-    final PsiElement referent = reference.resolve();
-    if (referent == null) {
-      return null;
-    }
-    if (!(referent instanceof PsiField)) {
-      return null;
-    }
-    final PsiField field = (PsiField)referent;
-    final PsiClass fieldContainingClass = field.getContainingClass();
-    final PsiClass methodContainingClass = method.getContainingClass();
-    if (!InheritanceUtil.isInheritorOrSelf(methodContainingClass, fieldContainingClass, true)) {
-      return null;
-    }
-    final PsiExpression rhs = assignment.getRExpression();
-    if (!(rhs instanceof PsiReferenceExpression)) {
-      return null;
-    }
-    final PsiReferenceExpression rReference = (PsiReferenceExpression)rhs;
-    final PsiExpression rQualifier = rReference.getQualifierExpression();
-    if (rQualifier != null) {
-      return null;
-    }
-    final PsiElement rReferent = rReference.resolve();
-    if (rReferent == null) {
-      return null;
-    }
-    if (!(rReferent instanceof PsiParameter)) {
-      return null;
-    }
-    final PsiType fieldType = field.getType();
-    final PsiType parameterType = ((PsiVariable)rReferent).getType();
-    if (fieldType.equalsToText(parameterType.getCanonicalText())) {
-      return field;
-    }
-    else {
-      return null;
-    }
-  }
-
-  public static boolean isSimpleSetter(PsiMethod method) {
-    return getFieldOfSetter(method) != null;
-  }
-
-  @Nullable
-  public static PsiMethod getReversePropertyMethod(PsiMethod propertyMethod) {
-    if (propertyMethod == null) {
-      return null;
-    }
-    final PsiClass aClass = propertyMethod.getContainingClass();
-    if (aClass == null) {
-      return null;
-    }
-    final String methodName = propertyMethod.getName();
-    final String prefix;
-    if (methodName.startsWith("get")) {
-      prefix = "get";
-    }
-    else if (methodName.startsWith("is")) {
-      prefix = "is";
-    }
-    else if (methodName.startsWith("set")) {
-      prefix = "set";
-    }
-    else {
-      return null;
-    }
-    final String name = methodName.substring(prefix.length());
-    final PsiField field;
-    if (prefix.equals("set")) {
-      field = getFieldOfSetter(propertyMethod);
-    }
-    else {
-      field = getFieldOfGetter(propertyMethod);
-    }
-    if (field == null) {
-      return null;
-    }
-    if (prefix.equals("set")) {
-      final PsiMethod result = findPropertyMethod(aClass, "get", name, field);
-      if (result != null) {
-        return result;
-      }
-      return findPropertyMethod(aClass, "is", name, field);
-    }
-    else {
-      return findPropertyMethod(aClass, "set", name, field);
-    }
-  }
-
-  private static PsiMethod findPropertyMethod(@NotNull PsiClass aClass, @NotNull String prefix, @NotNull String propertyName, @NotNull PsiField field1) {
-    final PsiMethod[] methods = aClass.findMethodsByName(prefix + propertyName, true);
-    for (PsiMethod method : methods) {
-      final PsiField field2;
-      if (prefix.equals("set")) {
-        field2 = getFieldOfSetter(method);
-      }
-      else {
-        field2 = getFieldOfGetter(method);
-      }
-      if (field1.equals(field2)) {
-        return method;
-      }
-    }
-    return null;
-  }
-}
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 785c5da..4f3bf58 100644
--- a/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java
@@ -23,6 +23,9 @@
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiMethod;
+import com.intellij.psi.PsiParameter;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+import com.intellij.psi.codeStyle.VariableKind;
 import com.intellij.psi.impl.beanProperties.BeanProperty;
 import com.intellij.psi.util.PropertyUtil;
 import com.intellij.refactoring.RenameRefactoring;
@@ -65,6 +68,15 @@
     if (setter != null) {
       final String setterName = PropertyUtil.suggestSetterName(newName);
       rename.addElement(setter, setterName);
+
+      final PsiParameter[] setterParameters = setter.getParameterList().getParameters();
+      if (setterParameters.length == 1) {
+        final JavaCodeStyleManager manager = JavaCodeStyleManager.getInstance(psiElement.getProject());
+        final String suggestedParameterName = manager.propertyNameToVariableName(property.getName(), VariableKind.PARAMETER);
+        if (suggestedParameterName.equals(setterParameters[0].getName())) {
+          rename.addElement(setterParameters[0], manager.propertyNameToVariableName(newName, VariableKind.PARAMETER));
+        }
+      }
     }
 
     final PsiMethod getter = property.getGetter();
diff --git a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaVariableProcessor.java b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaVariableProcessor.java
index 1573362..7e485dc 100644
--- a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaVariableProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaVariableProcessor.java
@@ -260,6 +260,16 @@
   }
 
   @Override
+  public void findExistingNameConflicts(PsiElement element,
+                                        String newName,
+                                        MultiMap<PsiElement, String> conflicts,
+                                        Map<PsiElement, String> allRenames) {
+    for (PsiElement psiElement : allRenames.keySet()) {
+      RenamePsiElementProcessor.forElement(psiElement).findExistingNameConflicts(psiElement, allRenames.get(psiElement), conflicts);
+    }
+  }
+
+  @Override
   public void findExistingNameConflicts(PsiElement element, String newName, MultiMap<PsiElement, String> conflicts) {
     if (element instanceof PsiCompiledElement) return;
     if (element instanceof PsiField) {
diff --git a/java/java-impl/src/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryProcessor.java b/java/java-impl/src/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryProcessor.java
index 2f7af47..202a990 100644
--- a/java/java-impl/src/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryProcessor.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.refactoring.replaceConstructorWithFactory;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
@@ -30,7 +31,6 @@
 import com.intellij.refactoring.util.RefactoringUIUtil;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.VisibilityUtil;
 import com.intellij.util.containers.MultiMap;
@@ -300,11 +300,11 @@
   protected String getCommandName() {
     if (myConstructor != null) {
       return RefactoringBundle.message("replace.constructor.0.with.a.factory.method",
-                                       UsageViewUtil.getDescriptiveName(myConstructor));
+                                       DescriptiveNameUtil.getDescriptiveName(myConstructor));
     }
     else {
       return RefactoringBundle.message("replace.default.constructor.of.0.with.a.factory.method",
-                                       UsageViewUtil.getDescriptiveName(myOriginalClass));
+                                       DescriptiveNameUtil.getDescriptiveName(myOriginalClass));
     }
   }
 
diff --git a/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java b/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java
index 871c964..ccdeb37 100644
--- a/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.refactoring.safeDelete;
 
-import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableFix;
+import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableUtil;
 import com.intellij.find.findUsages.PsiElement2UsageTargetAdapter;
 import com.intellij.ide.util.SuperMethodWarningUtil;
 import com.intellij.openapi.application.ApplicationManager;
@@ -88,7 +88,9 @@
         boolean hasSideEffects = false;
         if (PsiUtil.isOnAssignmentLeftHand(referencedElement)) {
           hasSideEffects =
-            RemoveUnusedVariableFix.checkSideEffects(((PsiAssignmentExpression)referencedElement.getParent()).getRExpression(), ((PsiLocalVariable)element), new ArrayList<PsiElement>());
+            RemoveUnusedVariableUtil
+              .checkSideEffects(((PsiAssignmentExpression)referencedElement.getParent()).getRExpression(), ((PsiLocalVariable)element),
+                                new ArrayList<PsiElement>());
         }
         usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(statement, element, isSafeToDelete && !hasSideEffects));
       }
diff --git a/java/java-impl/src/com/intellij/refactoring/safeDelete/usageInfo/SafeDeleteExtendsClassUsageInfo.java b/java/java-impl/src/com/intellij/refactoring/safeDelete/usageInfo/SafeDeleteExtendsClassUsageInfo.java
index 6d7f6c5..4b586aa 100644
--- a/java/java-impl/src/com/intellij/refactoring/safeDelete/usageInfo/SafeDeleteExtendsClassUsageInfo.java
+++ b/java/java-impl/src/com/intellij/refactoring/safeDelete/usageInfo/SafeDeleteExtendsClassUsageInfo.java
@@ -50,7 +50,7 @@
     final PsiReferenceList extendingImplementsList = myExtendingClass.getImplementsList();
     if (extendsList != null) {
       final PsiClassType[] referenceTypes = extendsList.getReferencedTypes();
-      final PsiReferenceList listToAddExtends = refClass.isInterface() == myExtendingClass.isInterface() ? myExtendingClass.getExtendsList() : extendingImplementsList;
+      final PsiReferenceList listToAddExtends = refClass.isInterface() == myExtendingClass.isInterface() || myExtendingClass instanceof PsiTypeParameter ? myExtendingClass.getExtendsList() : extendingImplementsList;
       final PsiClassType[] existingRefTypes = listToAddExtends.getReferencedTypes();
       for (PsiClassType referenceType : referenceTypes) {
         if (ArrayUtilRt.find(existingRefTypes, referenceType) > -1) continue;
diff --git a/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessor.java b/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessor.java
index 90372d7..210b8d3 100644
--- a/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessor.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.refactoring.turnRefsToSuper;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
@@ -52,7 +53,7 @@
 
   protected String getCommandName() {
     return RefactoringBundle.message("turn.refs.to.super.command",
-                                     UsageViewUtil.getDescriptiveName(myClass), UsageViewUtil.getDescriptiveName(mySuper));
+                                     DescriptiveNameUtil.getDescriptiveName(myClass), DescriptiveNameUtil.getDescriptiveName(mySuper));
   }
 
   @NotNull
diff --git a/java/java-impl/src/com/intellij/refactoring/typeCook/TypeCookDialog.java b/java/java-impl/src/com/intellij/refactoring/typeCook/TypeCookDialog.java
index c176555..9c723f4 100644
--- a/java/java-impl/src/com/intellij/refactoring/typeCook/TypeCookDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/typeCook/TypeCookDialog.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.refactoring.typeCook;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.openapi.help.HelpManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.text.StringUtil;
@@ -63,7 +64,7 @@
       PsiElement element = elements[i];
       name.append(StringUtil.capitalize(UsageViewUtil.getType(element)));
       name.append(" ");
-      name.append(UsageViewUtil.getDescriptiveName(element));
+      name.append(DescriptiveNameUtil.getDescriptiveName(element));
       if (i < elements.length - 1) {
         name.append("<br>");
       }
diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java
index 67e6438..105c383 100644
--- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java
+++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java
@@ -415,24 +415,25 @@
   public static PsiType substituteType(final PsiType migrationTtype, final PsiType originalType, final boolean isContraVariantPosition) {
     if ( originalType instanceof PsiClassType && migrationTtype instanceof PsiClassType) {
       final PsiClass originalClass = ((PsiClassType)originalType).resolve();
-      if (isContraVariantPosition && TypeConversionUtil.erasure(originalType).isAssignableFrom(TypeConversionUtil.erasure(migrationTtype))) {
-        final PsiClass psiClass = ((PsiClassType)migrationTtype).resolve();
-        final PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(originalClass, psiClass, PsiSubstitutor.EMPTY);
-        if (substitutor != null) {
-          final PsiType psiType =
-              substituteType(migrationTtype, originalType, false, psiClass, JavaPsiFacade.getElementFactory(psiClass.getProject()).createType(originalClass, substitutor));
+      if (originalClass != null) {
+        if (isContraVariantPosition && TypeConversionUtil.erasure(originalType).isAssignableFrom(TypeConversionUtil.erasure(migrationTtype))) {
+          final PsiClass psiClass = ((PsiClassType)migrationTtype).resolve();
+          final PsiSubstitutor substitutor = psiClass != null ? TypeConversionUtil.getClassSubstitutor(originalClass, psiClass, PsiSubstitutor.EMPTY) : null;
+          if (substitutor != null) {
+            final PsiType psiType =
+                substituteType(migrationTtype, originalType, false, psiClass, JavaPsiFacade.getElementFactory(psiClass.getProject()).createType(originalClass, substitutor));
+            if (psiType != null) {
+              return psiType;
+            }
+          }
+        }
+        else if (!isContraVariantPosition && TypeConversionUtil.erasure(migrationTtype).isAssignableFrom(TypeConversionUtil.erasure(originalType))) {
+          final PsiType psiType = substituteType(migrationTtype, originalType, false, originalClass, JavaPsiFacade.getElementFactory(originalClass.getProject()).createType(originalClass, PsiSubstitutor.EMPTY));
           if (psiType != null) {
             return psiType;
           }
         }
       }
-      else if (!isContraVariantPosition && TypeConversionUtil.erasure(migrationTtype).isAssignableFrom(TypeConversionUtil.erasure(
-        originalType))) {
-        final PsiType psiType = substituteType(migrationTtype, originalType, false, originalClass, JavaPsiFacade.getElementFactory(originalClass.getProject()).createType(originalClass, PsiSubstitutor.EMPTY));
-        if (psiType != null) {
-          return psiType;
-        }
-      }
     }
     return migrationTtype;
   }
diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationProcessor.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationProcessor.java
index 7a0bdb6..2f85e7a 100644
--- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationProcessor.java
@@ -26,7 +26,7 @@
 import com.intellij.psi.*;
 import com.intellij.psi.impl.PsiImplUtil;
 import com.intellij.psi.impl.source.tree.JavaElementType;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.PsiUtilCore;
 import com.intellij.refactoring.BaseRefactoringProcessor;
 import com.intellij.refactoring.typeMigration.ui.FailedConversionsDialog;
 import com.intellij.refactoring.typeMigration.ui.MigrationPanel;
@@ -76,7 +76,7 @@
     }
     return new PsiElement[]{root};
   }
-  
+
   public TypeMigrationProcessor(final Project project, final PsiElement[] roots, final TypeMigrationRules rules) {
     super(project);
     myRoot = roots;
@@ -106,7 +106,7 @@
                 result.add(element);
               }
             }
-            if (editor != null) RefactoringUtil.highlightAllOccurrences(project, PsiUtilBase.toPsiElementArray(result), editor);
+            if (editor != null) RefactoringUtil.highlightAllOccurrences(project, PsiUtilCore.toPsiElementArray(result), editor);
           }
         });
       }
diff --git a/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java b/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java
index f21c11a..7f13923 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java
@@ -20,13 +20,13 @@
  */
 package com.intellij.refactoring.util;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.source.resolve.FileContextUtil;
 import com.intellij.psi.search.searches.ClassInheritorsSearch;
 import com.intellij.psi.util.PsiFormatUtil;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.refactoring.RefactoringBundle;
-import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.Processor;
 import com.intellij.util.containers.MultiMap;
 import org.jetbrains.annotations.NotNull;
@@ -74,7 +74,7 @@
       }
       else { // method somewhere in base class
         if (JavaPsiFacade.getInstance(method.getProject()).getResolveHelper().isAccessible(method, aClass, null)) {
-          String className = CommonRefactoringUtil.htmlEmphasize(UsageViewUtil.getDescriptiveName(method.getContainingClass()));
+          String className = CommonRefactoringUtil.htmlEmphasize(DescriptiveNameUtil.getDescriptiveName(method.getContainingClass()));
           if (PsiUtil.getAccessLevel(prototype.getModifierList()) >= PsiUtil.getAccessLevel(method.getModifierList()) ) {
             boolean isMethodAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);
             boolean isMyMethodAbstract = refactoredMethod != null && refactoredMethod.hasModifierProperty(PsiModifier.ABSTRACT);
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 c02644f..527c030 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/InlineUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/InlineUtil.java
@@ -16,7 +16,7 @@
 package com.intellij.refactoring.util;
 
 import com.intellij.codeInsight.ChangeContextUtil;
-import com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaGenericsUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.util.Comparing;
@@ -58,7 +58,7 @@
     PsiType exprType = expr.getType();
     if (exprType != null && (!varType.equals(exprType) && (varType instanceof PsiPrimitiveType || exprType instanceof PsiPrimitiveType)
                              || !TypeConversionUtil.isAssignable(varType, exprType)
-                             || insertCastWhenUnchecked && GenericsHighlightUtil.isRawToGeneric(varType, exprType))) {
+                             || insertCastWhenUnchecked && JavaGenericsUtil.isRawToGeneric(varType, exprType))) {
       boolean matchedTypes = false;
       //try explicit type arguments
       final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
diff --git a/java/java-impl/src/com/intellij/refactoring/util/JavaRefactoringElementDescriptionProvider.java b/java/java-impl/src/com/intellij/refactoring/util/JavaRefactoringElementDescriptionProvider.java
index 8e691a6..2b0163c 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/JavaRefactoringElementDescriptionProvider.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/JavaRefactoringElementDescriptionProvider.java
@@ -15,10 +15,10 @@
  */
 package com.intellij.refactoring.util;
 
+import com.intellij.lang.findUsages.DescriptiveNameUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiFormatUtil;
 import com.intellij.refactoring.RefactoringBundle;
-import com.intellij.usageView.UsageViewUtil;
 import org.jetbrains.annotations.NotNull;
 
 public class JavaRefactoringElementDescriptionProvider implements ElementDescriptionProvider {
@@ -71,7 +71,8 @@
     if ((element instanceof PsiClass)) {
       //TODO : local & anonymous
       PsiClass psiClass = (PsiClass) element;
-      return RefactoringBundle.message("class.description", CommonRefactoringUtil.htmlEmphasize(UsageViewUtil.getDescriptiveName(psiClass)));
+      return RefactoringBundle.message("class.description", CommonRefactoringUtil.htmlEmphasize(
+        DescriptiveNameUtil.getDescriptiveName(psiClass)));
     }
     return null;
   }
diff --git a/java/java-impl/src/com/intellij/refactoring/util/ParameterTablePanel.java b/java/java-impl/src/com/intellij/refactoring/util/ParameterTablePanel.java
index 218607a..256c3a9 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/ParameterTablePanel.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/ParameterTablePanel.java
@@ -59,23 +59,6 @@
     return myVariableData;
   }
 
-  public static class VariableData {
-    public final PsiVariable variable;
-    public PsiType type;
-    public String name;
-    public boolean passAsParameter;
-
-    public VariableData(PsiVariable var) {
-      variable = var;
-      type = var.getType();
-    }
-
-    public VariableData(PsiVariable var, PsiType type) {
-      variable = var;
-      this.type = SmartTypePointerManager.getInstance(var.getProject()).createSmartTypePointer(type).getType();
-    }
-  }
-
   protected abstract void updateSignature();
 
   protected abstract void doEnterAction();
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 b30b63c..80a4a91 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
@@ -18,6 +18,7 @@
 import com.intellij.codeInsight.ExpectedTypeInfo;
 import com.intellij.codeInsight.ExpectedTypesProvider;
 import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
 import com.intellij.codeInsight.highlighting.HighlightManager;
 import com.intellij.lang.java.JavaLanguage;
 import com.intellij.openapi.diagnostic.Logger;
@@ -822,21 +823,6 @@
     return buffer.toString();
   }
 
-  public static boolean isSuperOrThisCall(PsiStatement statement, boolean testForSuper, boolean testForThis) {
-    if (!(statement instanceof PsiExpressionStatement)) return false;
-    PsiExpression expression = ((PsiExpressionStatement)statement).getExpression();
-    if (!(expression instanceof PsiMethodCallExpression)) return false;
-    final PsiReferenceExpression methodExpression = ((PsiMethodCallExpression)expression).getMethodExpression();
-    if (testForSuper) {
-      if ("super".equals(methodExpression.getText())) return true;
-    }
-    if (testForThis) {
-      if ("this".equals(methodExpression.getText())) return true;
-    }
-
-    return false;
-  }
-
   public static void visitImplicitSuperConstructorUsages(PsiClass subClass,
                                                          final ImplicitConstructorUsageVisitor implicitConstructorUsageVistor,
                                                          PsiClass superClass) {
@@ -845,7 +831,7 @@
     if (constructors.length > 0) {
       for (PsiMethod constructor : constructors) {
         final PsiStatement[] statements = constructor.getBody().getStatements();
-        if (statements.length < 1 || !isSuperOrThisCall(statements[0], true, true)) {
+        if (statements.length < 1 || !JavaHighlightUtil.isSuperOrThisCall(statements[0], true, true)) {
           implicitConstructorUsageVistor.visitConstructor(constructor, baseDefaultConstructor);
         }
       }
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/BreakReturnValue.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/BreakReturnValue.java
deleted file mode 100644
index 6b4652c..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/BreakReturnValue.java
+++ /dev/null
@@ -1,34 +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.
- */
-
-/*
- * User: anna
- * Date: 23-Oct-2008
- */
-package com.intellij.refactoring.util.duplicates;
-
-import org.jetbrains.annotations.NonNls;
-
-public class BreakReturnValue extends GotoReturnValue{
-  public boolean isEquivalent(final ReturnValue other) {
-    return other instanceof BreakReturnValue;
-  }
-
-  @NonNls
-  public String getGotoStatement() {
-    return "if(a) break;";
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ConditionalReturnStatementValue.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/ConditionalReturnStatementValue.java
deleted file mode 100644
index 3878619..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ConditionalReturnStatementValue.java
+++ /dev/null
@@ -1,60 +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.refactoring.util.duplicates;
-
-import com.intellij.codeInsight.PsiEquivalenceUtil;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.util.IncorrectOperationException;
-
-/**
- * @author ven
- */
-public class ConditionalReturnStatementValue implements ReturnValue {
-  PsiExpression myReturnValue;
-
-  public ConditionalReturnStatementValue(final PsiExpression returnValue) {
-    myReturnValue = returnValue;
-  }
-
-  public boolean isEquivalent(ReturnValue other) {
-    if (!(other instanceof ConditionalReturnStatementValue)) return false;
-    PsiExpression otherReturnValue = ((ConditionalReturnStatementValue) other).myReturnValue;
-    if (otherReturnValue == null || myReturnValue == null) return myReturnValue == null && otherReturnValue == null;
-    return PsiEquivalenceUtil.areElementsEquivalent(myReturnValue, otherReturnValue);
-  }
-
-  public PsiStatement createReplacement(final PsiMethod extractedMethod, PsiMethodCallExpression methodCallExpression) throws IncorrectOperationException {
-    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(methodCallExpression.getProject()).getElementFactory();
-    PsiIfStatement statement;
-    if (myReturnValue == null) {
-      statement = (PsiIfStatement)elementFactory.createStatementFromText("if(a) return;", null);
-    }
-    else {
-      statement = (PsiIfStatement)elementFactory.createStatementFromText("if(a) return b;", null);
-      final PsiReturnStatement thenBranch = (PsiReturnStatement)statement.getThenBranch();
-      assert thenBranch != null;
-      final PsiExpression returnValue = thenBranch.getReturnValue();
-      assert returnValue != null;
-      returnValue.replace(myReturnValue);
-    }
-
-    final PsiExpression condition = statement.getCondition();
-    assert condition != null;
-    condition.replace(methodCallExpression);
-    return (PsiStatement)CodeStyleManager.getInstance(statement.getManager().getProject()).reformat(statement);
-  }
-}
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ContinueReturnValue.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/ContinueReturnValue.java
deleted file mode 100644
index 6bbf632..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ContinueReturnValue.java
+++ /dev/null
@@ -1,35 +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.
- */
-
-/*
- * User: anna
- * Date: 23-Oct-2008
- */
-package com.intellij.refactoring.util.duplicates;
-
-import org.jetbrains.annotations.NonNls;
-
-public class ContinueReturnValue extends GotoReturnValue {
-  public boolean isEquivalent(final ReturnValue other) {
-    return other instanceof ContinueReturnValue;
-  }
-
-
-  @NonNls
-  public String getGotoStatement() {
-    return "if (a) continue;";
-  }
-}
\ No newline at end of file
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
deleted file mode 100644
index b6d8a55..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesFinder.java
+++ /dev/null
@@ -1,640 +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.refactoring.util.duplicates;
-
-import com.intellij.codeInsight.PsiEquivalenceUtil;
-import com.intellij.lang.ASTNode;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.Pair;
-import com.intellij.psi.*;
-import com.intellij.psi.controlFlow.*;
-import com.intellij.psi.impl.source.PsiImmediateClassType;
-import com.intellij.psi.tree.IElementType;
-import com.intellij.psi.util.*;
-import com.intellij.refactoring.extractMethod.InputVariables;
-import com.intellij.refactoring.util.RefactoringChangeUtil;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.containers.IntArrayList;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.*;
-
-/**
- * @author dsl
- */
-public class DuplicatesFinder {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.util.duplicates.DuplicatesFinder");
-  public static final Key<Pair<PsiVariable, PsiType>> PARAMETER = Key.create("PARAMETER");
-  private final PsiElement[] myPattern;
-  private InputVariables myParameters;
-  private final List<? extends PsiVariable> myOutputParameters;
-  private final List<PsiElement> myPatternAsList;
-  private boolean myMultipleExitPoints = false;
-  @Nullable private final ReturnValue myReturnValue;
-
-  public DuplicatesFinder(PsiElement[] pattern,
-                          InputVariables parameters,
-                          @Nullable ReturnValue returnValue,
-                          @NotNull List<? extends PsiVariable> outputParameters
-  ) {
-    myReturnValue = returnValue;
-    LOG.assertTrue(pattern.length > 0);
-    myPattern = pattern;
-    myPatternAsList = Arrays.asList(myPattern);
-    myParameters = parameters;
-    myOutputParameters = outputParameters;
-
-    final PsiElement codeFragment = ControlFlowUtil.findCodeFragment(pattern[0]);
-    try {
-      final ControlFlow controlFlow = ControlFlowFactory.getInstance(codeFragment.getProject()).getControlFlow(codeFragment, new LocalsControlFlowPolicy(codeFragment), false);
-
-      int startOffset;
-      int i = 0;
-      do {
-        startOffset = controlFlow.getStartOffset(pattern[i++]);
-      } while(startOffset < 0 && i < pattern.length);
-
-      int endOffset;
-      int j = pattern.length - 1;
-      do {
-        endOffset = controlFlow.getEndOffset(pattern[j--]);
-      } while(endOffset < 0 && j >= 0);
-
-      IntArrayList exitPoints = new IntArrayList();
-      final Collection<PsiStatement> exitStatements = ControlFlowUtil
-          .findExitPointsAndStatements(controlFlow, startOffset, endOffset, exitPoints, ControlFlowUtil.DEFAULT_EXIT_STATEMENTS_CLASSES);
-      myMultipleExitPoints = exitPoints.size() > 1;
-
-      if (myMultipleExitPoints) {
-        myParameters.removeParametersUsedInExitsOnly(codeFragment, exitStatements, controlFlow, startOffset, endOffset);
-      }
-    }
-    catch (AnalysisCanceledException e) {
-    }
-  }
-
-  public DuplicatesFinder(final PsiElement[] pattern,
-                          final InputVariables psiParameters,
-                          final List<? extends PsiVariable> psiVariables) {
-    this(pattern, psiParameters, null, psiVariables);
-  }
-
-
-
-
-  public List<Match> findDuplicates(PsiElement scope) {
-    annotatePattern();
-    final ArrayList<Match> result = new ArrayList<Match>();
-    findPatternOccurrences(result, scope);
-    deannotatePattern();
-    return result;
-  }
-
-  @Nullable
-  public Match isDuplicate(PsiElement element, boolean ignoreParameterTypes) {
-    annotatePattern();
-    Match match = isDuplicateFragment(element, ignoreParameterTypes);
-    deannotatePattern();
-    return match;
-  }
-
-  private void annotatePattern() {
-    for (final PsiElement patternComponent : myPattern) {
-      patternComponent.accept(new JavaRecursiveElementWalkingVisitor() {
-        @Override public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
-          final PsiElement element = reference.resolve();
-          if (element instanceof PsiVariable) {
-            final PsiVariable variable = (PsiVariable)element;
-            PsiType type = variable.getType();
-            myParameters.annotateWithParameter(reference);
-            if (myOutputParameters.contains(element)) {
-              reference.putUserData(PARAMETER, Pair.create(variable, type));
-            }
-          }
-          PsiElement qualifier = reference.getQualifier();
-          if (qualifier != null) {
-            qualifier.accept(this);
-          }
-        }
-      });
-    }
-  }
-
-  private void deannotatePattern() {
-    for (final PsiElement patternComponent : myPattern) {
-      patternComponent.accept(new JavaRecursiveElementWalkingVisitor() {
-        @Override public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
-          if (reference.getUserData(PARAMETER) != null) {
-            reference.putUserData(PARAMETER, null);
-          }
-        }
-      });
-    }
-  }
-
-  private void findPatternOccurrences(List<Match> array, PsiElement scope) {
-    PsiElement[] children = scope.getChildren();
-    for (PsiElement child : children) {
-      final Match match = isDuplicateFragment(child, false);
-      if (match != null) {
-        array.add(match);
-        continue;
-      }
-      findPatternOccurrences(array, child);
-    }
-  }
-
-
-  @Nullable
-  private Match isDuplicateFragment(PsiElement candidate, boolean ignoreParameterTypes) {
-    for (PsiElement pattern : myPattern) {
-      if (PsiTreeUtil.isAncestor(pattern, candidate, false)) return null;
-    }
-    PsiElement sibling = candidate;
-    ArrayList<PsiElement> candidates = new ArrayList<PsiElement>();
-    for (final PsiElement element : myPattern) {
-      if (sibling == null) return null;
-      if (!canBeEquivalent(element, sibling)) return null;
-      candidates.add(sibling);
-      sibling = PsiTreeUtil.skipSiblingsForward(sibling, PsiWhiteSpace.class, PsiComment.class);
-    }
-    LOG.assertTrue(myPattern.length == candidates.size());
-    if (myPattern.length == 1 && myPattern[0] instanceof PsiExpression) {
-      if (candidates.get(0) instanceof PsiExpression) {
-        final PsiExpression candidateExpression = (PsiExpression)candidates.get(0);
-        if (PsiUtil.isAccessedForWriting(candidateExpression)) return null;
-        final PsiType patternType = ((PsiExpression)myPattern[0]).getType();
-        final PsiType candidateType = candidateExpression.getType();
-        PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
-        final PsiMethod method = PsiTreeUtil.getParentOfType(myPattern[0], PsiMethod.class);
-        if (method != null) {
-          final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(candidate.getProject()).getResolveHelper();
-          substitutor = resolveHelper.inferTypeArguments(method.getTypeParameters(), new PsiType[]{patternType},
-                                                         new PsiType[]{candidateType}, PsiUtil.getLanguageLevel(method));
-        }
-        if (!canTypesBeEquivalent(substitutor.substitute(patternType), candidateType)) return null;
-      }
-      else {
-        return null;
-      }
-
-    }
-    final Match match = new Match(candidates.get(0), candidates.get(candidates.size() - 1), ignoreParameterTypes);
-    for (int i = 0; i < myPattern.length; i++) {
-      if (!matchPattern(myPattern[i], candidates.get(i), candidates, match)) return null;
-    }
-
-    if (checkPostVariableUsages(candidates, match)) return null;
-
-    return match;
-  }
-
-  private boolean checkPostVariableUsages(final ArrayList<PsiElement> candidates, final Match match) {
-    final PsiElement codeFragment = ControlFlowUtil.findCodeFragment(candidates.get(0));
-    try {
-      final ControlFlow controlFlow = ControlFlowFactory.getInstance(codeFragment.getProject()).getControlFlow(codeFragment, new LocalsControlFlowPolicy(codeFragment), false);
-
-      int startOffset;
-      int i = 0;
-      do {
-        startOffset = controlFlow.getStartOffset(candidates.get(i++));
-      } while(startOffset < 0 && i < candidates.size());
-
-      int endOffset;
-      int j = candidates.size() - 1;
-      do {
-        endOffset = controlFlow.getEndOffset(candidates.get(j--));
-      } while(endOffset < 0 && j >= 0);
-
-      final IntArrayList exitPoints = new IntArrayList();
-      ControlFlowUtil.findExitPointsAndStatements(controlFlow, startOffset, endOffset, exitPoints, ControlFlowUtil.DEFAULT_EXIT_STATEMENTS_CLASSES);
-      final PsiVariable[] outVariables = ControlFlowUtil.getOutputVariables(controlFlow, startOffset, endOffset, exitPoints.toArray());
-
-      if (outVariables.length > 0) {
-        if (outVariables.length == 1) {
-          ReturnValue returnValue = match.getReturnValue();
-          if (returnValue == null) {
-            returnValue = myReturnValue;
-          }
-          if (returnValue instanceof VariableReturnValue) {
-            final ReturnValue value = match.getOutputVariableValue(((VariableReturnValue)returnValue).getVariable());
-            if (value != null) {
-              if (value.isEquivalent(new VariableReturnValue(outVariables[0]))) return false;
-              if (value instanceof ExpressionReturnValue) {
-                final PsiExpression expression = ((ExpressionReturnValue)value).getExpression();
-                if (expression instanceof PsiReferenceExpression) {
-                  final PsiElement variable = ((PsiReferenceExpression)expression).resolve();
-                  return variable == null || !PsiEquivalenceUtil.areElementsEquivalent(variable, outVariables[0]);
-                }
-              }
-            }
-          }
-        }
-        return true;
-      }
-    }
-    catch (AnalysisCanceledException e) {
-    }
-    return false;
-  }
-
-  private static boolean canTypesBeEquivalent(PsiType type1, PsiType type2) {
-    if (type1 == null || type2 == null) return false;
-    if (!type2.isAssignableFrom(type1)) {
-      if (type1 instanceof PsiImmediateClassType && type2 instanceof PsiImmediateClassType) {
-        final PsiClass psiClass1 = ((PsiImmediateClassType)type1).resolve();
-        final PsiClass psiClass2 = ((PsiImmediateClassType)type2).resolve();
-        if (!(psiClass1 instanceof PsiAnonymousClass &&
-              psiClass2 instanceof PsiAnonymousClass &&
-              psiClass1.getManager().areElementsEquivalent(((PsiAnonymousClass)psiClass1).getBaseClassType().resolve(),
-                                                           ((PsiAnonymousClass)psiClass2).getBaseClassType().resolve()))) {
-          return false;
-        }
-      }
-      else {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  private static boolean canBeEquivalent(final PsiElement pattern, PsiElement candidate) {
-    if (pattern instanceof PsiReturnStatement && candidate instanceof PsiExpressionStatement) return true;
-    if (pattern instanceof PsiReturnStatement && candidate instanceof PsiDeclarationStatement) return true;
-    if (pattern instanceof PsiThisExpression && candidate instanceof PsiReferenceExpression) return true;
-    final ASTNode node1 = pattern.getNode();
-    final ASTNode node2 = candidate.getNode();
-    if (node1 == null || node2 == null) return false;
-    return node1.getElementType() == node2.getElementType();
-  }
-
-  private boolean matchPattern(PsiElement pattern,
-                               PsiElement candidate,
-                               List<PsiElement> candidates,
-                               Match match) {
-    if (pattern == null || candidate == null) return pattern == candidate;
-    if (pattern.getUserData(PARAMETER) != null) {
-      final Pair<PsiVariable, PsiType> parameter = pattern.getUserData(PARAMETER);
-      return match.putParameter(parameter, candidate);
-    }
-
-    if (!canBeEquivalent(pattern, candidate)) return false; // Q : is it correct to check implementation classes?
-
-    if (pattern instanceof PsiExpressionList && candidate instanceof PsiExpressionList) { //check varargs
-      final PsiExpression[] expressions = ((PsiExpressionList)pattern).getExpressions();
-      final PsiExpression[] childExpressions = ((PsiExpressionList)candidate).getExpressions();
-      if (expressions.length > 0 && expressions[expressions.length - 1] instanceof PsiReferenceExpression) {
-        final PsiElement resolved = ((PsiReferenceExpression)expressions[expressions.length - 1]).resolve();
-        if (resolved instanceof PsiParameter && ((PsiParameter)resolved).getType() instanceof PsiEllipsisType) {
-          for(int i = 0; i < expressions.length - 1; i++) {
-            final Pair<PsiVariable, PsiType> parameter = expressions[i].getUserData(PARAMETER);
-            if (parameter == null) {
-              if (!matchPattern(expressions[i], childExpressions[i], candidates, match)) {
-                return false;
-              }
-            } else if (!match.putParameter(parameter, childExpressions[i])) return false;
-          }
-          final Pair<PsiVariable, PsiType> param = expressions[expressions.length - 1].getUserData(PARAMETER);
-          if (param == null) return false;
-          for(int i = expressions.length - 1; i < childExpressions.length; i++) {
-            if (!match.putParameter(param, childExpressions[i])) return false;
-          }
-          return true;
-        }
-      }
-    }
-
-    if (pattern instanceof PsiAssignmentExpression) {
-      final PsiExpression lExpression = ((PsiAssignmentExpression)pattern).getLExpression();
-      if (lExpression.getType() instanceof PsiPrimitiveType &&
-          lExpression instanceof PsiReferenceExpression &&
-          ((PsiReferenceExpression)lExpression).resolve() instanceof PsiParameter) {
-        return false;
-      }
-    } else if (pattern instanceof PsiPrefixExpression) {
-      if (checkParameterModification(((PsiPrefixExpression)pattern).getOperand(), ((PsiPrefixExpression)pattern).getOperationTokenType(),
-                                     ((PsiPrefixExpression)candidate).getOperand())) return false;
-    } else if (pattern instanceof PsiPostfixExpression) {
-      if (checkParameterModification(((PsiPostfixExpression)pattern).getOperand(), ((PsiPostfixExpression)pattern).getOperationTokenType(),
-                                     ((PsiPostfixExpression)candidate).getOperand())) return false;
-    }
-
-    if (pattern instanceof PsiJavaCodeReferenceElement) {
-      final PsiElement resolveResult1 = ((PsiJavaCodeReferenceElement)pattern).resolve();
-      final PsiElement resolveResult2 = ((PsiJavaCodeReferenceElement)candidate).resolve();
-      if (resolveResult1 instanceof PsiClass && resolveResult2 instanceof PsiClass) return true;
-      if (isUnder(resolveResult1, myPatternAsList) && isUnder(resolveResult2, candidates)) {
-        traverseParameter(resolveResult1, resolveResult2, match);
-        return match.putDeclarationCorrespondence(resolveResult1, resolveResult2);
-      }
-      final PsiElement qualifier2 = ((PsiJavaCodeReferenceElement)candidate).getQualifier();
-      if (!equivalentResolve(resolveResult1, resolveResult2, qualifier2)) {
-        return false;
-      }
-      PsiElement qualifier1 = ((PsiJavaCodeReferenceElement)pattern).getQualifier();
-      if (qualifier1 instanceof PsiReferenceExpression && qualifier2 instanceof PsiReferenceExpression &&
-          !match.areCorrespond(((PsiReferenceExpression)qualifier1).resolve(), ((PsiReferenceExpression)qualifier2).resolve())) {
-        return false;
-      }
-
-    }
-
-    if (pattern instanceof PsiTypeCastExpression) {
-      final PsiTypeElement castTypeElement1 = ((PsiTypeCastExpression)pattern).getCastType();
-      final PsiTypeElement castTypeElement2 = ((PsiTypeCastExpression)candidate).getCastType();
-      if (castTypeElement1 != null && castTypeElement2 != null) {
-        final PsiType type1 = TypeConversionUtil.erasure(castTypeElement1.getType());
-        final PsiType type2 = TypeConversionUtil.erasure(castTypeElement2.getType());
-        if (!type1.equals(type2)) return false;
-      }
-    } else if (pattern instanceof PsiNewExpression) {
-      final PsiType type1 = ((PsiNewExpression)pattern).getType();
-      final PsiType type2 = ((PsiNewExpression)candidate).getType();
-      if (type1 == null || type2 == null) return false;
-      final PsiJavaCodeReferenceElement classReference1 = ((PsiNewExpression)pattern).getClassReference();
-      final PsiJavaCodeReferenceElement classReference2 = ((PsiNewExpression)candidate).getClassReference();
-      if (classReference1 != null && classReference2 != null) {
-        final PsiElement resolved1 = classReference1.resolve();
-        final PsiElement resolved2 = classReference2.resolve();
-        if (!pattern.getManager().areElementsEquivalent(resolved1, resolved2)) return false;
-      }
-      else {
-        if (!canTypesBeEquivalent(type1, type2)) return false;
-      }
-    } else if (pattern instanceof PsiClassObjectAccessExpression) {
-      final PsiTypeElement operand1 = ((PsiClassObjectAccessExpression)pattern).getOperand();
-      final PsiTypeElement operand2 = ((PsiClassObjectAccessExpression)candidate).getOperand();
-      return operand1.getType().equals(operand2.getType());
-    } else if (pattern instanceof PsiInstanceOfExpression) {
-      final PsiTypeElement operand1 = ((PsiInstanceOfExpression)pattern).getCheckType();
-      final PsiTypeElement operand2 = ((PsiInstanceOfExpression)candidate).getCheckType();
-      if (operand1 == null || operand2 == null) return false;
-      if (!operand1.getType().equals(operand2.getType())) return false;
-    } else if (pattern instanceof PsiReturnStatement) {
-      final PsiReturnStatement patternReturnStatement = (PsiReturnStatement)pattern;
-      return matchReturnStatement(patternReturnStatement, candidate, candidates, match);
-    } else if (pattern instanceof PsiContinueStatement) {
-      match.registerReturnValue(new ContinueReturnValue());
-    } else if (pattern instanceof PsiBreakStatement) {
-      match.registerReturnValue(new BreakReturnValue());
-    } else if (pattern instanceof PsiReferenceExpression) {
-      final PsiReferenceExpression patternRefExpr = (PsiReferenceExpression)pattern;
-      final PsiReferenceExpression candidateRefExpr = (PsiReferenceExpression)candidate;
-      final PsiExpression patternQualifier = patternRefExpr.getQualifierExpression();
-      final PsiExpression candidateQualifier = candidateRefExpr.getQualifierExpression();
-      if (patternQualifier == null) {
-        PsiClass contextClass = PsiTreeUtil.getParentOfType(pattern, PsiClass.class);
-        if (candidateQualifier instanceof PsiReferenceExpression) {
-          final PsiElement resolved = ((PsiReferenceExpression)candidateQualifier).resolve();
-          if (resolved instanceof PsiClass && contextClass != null && InheritanceUtil.isInheritorOrSelf(contextClass, (PsiClass)resolved, true)) {
-            return true;
-          }
-        }
-        return contextClass != null && match.registerInstanceExpression(candidateQualifier, contextClass);
-      } else {
-        if (candidateQualifier == null) {
-          if (patternQualifier instanceof PsiThisExpression) {
-            final PsiJavaCodeReferenceElement qualifier = ((PsiThisExpression)patternQualifier).getQualifier();
-            if (candidate instanceof PsiReferenceExpression) {
-              PsiElement contextClass = qualifier == null ? PsiTreeUtil.getParentOfType(pattern, PsiClass.class) : qualifier.resolve();
-              return contextClass instanceof PsiClass && match.registerInstanceExpression(((PsiReferenceExpression)candidate).getQualifierExpression(),
-                                                                                          (PsiClass)contextClass);
-            }
-          } else {
-            final PsiType type = patternQualifier.getType();
-            PsiClass contextClass = type instanceof PsiClassType ? ((PsiClassType)type).resolve() : null;
-            try {
-              final Pair<PsiVariable, PsiType> parameter = patternQualifier.getUserData(PARAMETER);
-
-              if (parameter != null) {
-                final PsiClass thisClass = RefactoringChangeUtil.getThisClass(parameter.first);
-
-                if (contextClass != null && InheritanceUtil.isInheritorOrSelf(thisClass, contextClass, true)) {
-                  contextClass = thisClass;
-                }
-                final PsiClass thisCandidate = RefactoringChangeUtil.getThisClass(candidate);
-                if (thisCandidate != null && InheritanceUtil.isInheritorOrSelf(thisCandidate, contextClass, true)) {
-                  contextClass = thisCandidate;
-                }
-                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) {
-                  final PsiClass classContext = PsiTreeUtil.getParentOfType(candidate, PsiClass.class);
-                  if (classContext != null && InheritanceUtil.isInheritorOrSelf(classContext, (PsiClass)resolved, true)) {
-                    return true;
-                  }
-                }
-              }
-
-              return false;
-            }
-            catch (IncorrectOperationException e) {
-              LOG.error(e);
-            }
-          }
-        } else {
-          if (patternQualifier instanceof PsiThisExpression && candidateQualifier instanceof PsiThisExpression) {
-            final PsiJavaCodeReferenceElement thisPatternQualifier = ((PsiThisExpression)patternQualifier).getQualifier();
-            final PsiElement patternContextClass = thisPatternQualifier == null ? PsiTreeUtil.getParentOfType(patternQualifier, PsiClass.class) : thisPatternQualifier.resolve();
-            final PsiJavaCodeReferenceElement thisCandidateQualifier = ((PsiThisExpression)candidateQualifier).getQualifier();
-            final PsiElement candidateContextClass = thisCandidateQualifier == null ? PsiTreeUtil.getParentOfType(candidateQualifier, PsiClass.class) : thisCandidateQualifier.resolve();
-            return patternContextClass == candidateContextClass;
-          }
-        }
-      }
-    } else if (pattern instanceof PsiThisExpression) {
-      final PsiJavaCodeReferenceElement qualifier = ((PsiThisExpression)pattern).getQualifier();
-      final PsiElement contextClass = qualifier == null ? PsiTreeUtil.getParentOfType(pattern, PsiClass.class) : qualifier.resolve();
-      if (candidate instanceof PsiReferenceExpression) {
-        final PsiElement parent = candidate.getParent();
-        return parent instanceof PsiReferenceExpression && contextClass instanceof PsiClass && match.registerInstanceExpression(((PsiReferenceExpression)parent).getQualifierExpression(),
-                                                                                    (PsiClass)contextClass);
-      } else if (candidate instanceof PsiThisExpression) {
-        final PsiJavaCodeReferenceElement candidateQualifier = ((PsiThisExpression)candidate).getQualifier();
-        final PsiElement candidateContextClass = candidateQualifier == null ? PsiTreeUtil.getParentOfType(candidate, PsiClass.class) : candidateQualifier.resolve();
-        return contextClass == candidateContextClass;
-      }
-    } else if (pattern instanceof PsiSuperExpression) {
-      final PsiJavaCodeReferenceElement qualifier = ((PsiSuperExpression)pattern).getQualifier();
-      final PsiElement contextClass = qualifier == null ? PsiTreeUtil.getParentOfType(pattern, PsiClass.class) : qualifier.resolve();
-      if (candidate instanceof PsiSuperExpression) {
-        final PsiJavaCodeReferenceElement candidateQualifier = ((PsiSuperExpression)candidate).getQualifier();
-        return contextClass == (candidateQualifier != null ? candidateQualifier.resolve() : PsiTreeUtil.getParentOfType(candidate, PsiClass.class));
-      }
-    }
-
-    PsiElement[] children1 = getFilteredChildren(pattern);
-    PsiElement[] children2 = getFilteredChildren(candidate);
-    if (children1.length != children2.length) return false;
-
-
-    for (int i = 0; i < children1.length; i++) {
-      PsiElement child1 = children1[i];
-      PsiElement child2 = children2[i];
-      if (!matchPattern(child1, child2, candidates, match)) return false;
-    }
-
-    if (children1.length == 0) {
-      if (pattern.getParent() instanceof PsiVariable && ((PsiVariable)pattern.getParent()).getNameIdentifier() == pattern) {
-        return match.putDeclarationCorrespondence(pattern.getParent(), candidate.getParent());
-      }
-      if (!pattern.textMatches(candidate)) return false;
-    }
-
-    return true;
-  }
-
-  private static boolean checkParameterModification(final PsiExpression expression,
-                                                    final IElementType sign,
-                                                    PsiExpression candidate) {
-    if (expression instanceof PsiReferenceExpression && ((PsiReferenceExpression)expression).resolve() instanceof PsiParameter &&
-        (sign.equals(JavaTokenType.MINUSMINUS)|| sign.equals(JavaTokenType.PLUSPLUS))) {
-      if (candidate instanceof PsiReferenceExpression && ((PsiReferenceExpression)candidate).resolve() instanceof PsiParameter) {
-        return false;
-      }
-      return true;
-    }
-    return false;
-  }
-
-  private static void traverseParameter(PsiElement pattern, PsiElement candidate, Match match) {
-    if (pattern == null || candidate == null) return;
-    if (pattern.getUserData(PARAMETER) != null) {
-      final Pair<PsiVariable, PsiType> parameter = pattern.getUserData(PARAMETER);
-      match.putParameter(parameter, candidate);
-      return;
-    }
-
-    PsiElement[] children1 = getFilteredChildren(pattern);
-    PsiElement[] children2 = getFilteredChildren(candidate);
-    if (children1.length != children2.length) return;
-
-    for (int i = 0; i < children1.length; i++) {
-      PsiElement child1 = children1[i];
-      PsiElement child2 = children2[i];
-      traverseParameter(child1, child2, match);
-    }
-  }
-
-  private boolean matchReturnStatement(final PsiReturnStatement patternReturnStatement,
-                                       PsiElement candidate,
-                                       List<PsiElement> candidates,
-                                       Match match) {
-    if (candidate instanceof PsiExpressionStatement) {
-      final PsiExpression expression = ((PsiExpressionStatement)candidate).getExpression();
-      if (expression instanceof PsiAssignmentExpression) {
-        final PsiExpression returnValue = patternReturnStatement.getReturnValue();
-        final PsiExpression rExpression = ((PsiAssignmentExpression)expression).getRExpression();
-        if (!matchPattern(returnValue, rExpression, candidates, match)) return false;
-        final PsiExpression lExpression = ((PsiAssignmentExpression)expression).getLExpression();
-        return match.registerReturnValue(new ExpressionReturnValue(lExpression));
-      }
-      else return false;
-    }
-    else if (candidate instanceof PsiDeclarationStatement) {
-      final PsiElement[] declaredElements = ((PsiDeclarationStatement)candidate).getDeclaredElements();
-      if (declaredElements.length != 1) return false;
-      if (!(declaredElements[0] instanceof PsiVariable)) return false;
-      final PsiVariable variable = (PsiVariable)declaredElements[0];
-      if (!matchPattern(patternReturnStatement.getReturnValue(), variable.getInitializer(), candidates, match)) return false;
-      return match.registerReturnValue(new VariableReturnValue(variable));
-    }
-    else if (candidate instanceof PsiReturnStatement) {
-      final PsiExpression returnValue = ((PsiReturnStatement)candidate).getReturnValue();
-      if (myMultipleExitPoints) {
-        return match.registerReturnValue(new ConditionalReturnStatementValue(returnValue));
-      }
-      else {
-        final PsiElement classOrLambda = PsiTreeUtil.getParentOfType(returnValue, PsiClass.class, PsiLambdaExpression.class);
-        final PsiElement commonParent = PsiTreeUtil.findCommonParent(match.getMatchStart(), match.getMatchEnd());
-        if (classOrLambda == null || !PsiTreeUtil.isAncestor(commonParent, classOrLambda, false)) {
-          if (returnValue != null && !match.registerReturnValue(ReturnStatementReturnValue.INSTANCE)) return false; //do not register return value for return; statement
-        }
-        return matchPattern(patternReturnStatement.getReturnValue(), returnValue, candidates, match);
-      }
-    }
-    else return false;
-  }
-
-  private static boolean equivalentResolve(final PsiElement resolveResult1, final PsiElement resolveResult2, PsiElement qualifier2) {
-    final boolean b = Comparing.equal(resolveResult1, resolveResult2);
-    if (b) return b;
-    if (resolveResult1 instanceof PsiMethod && resolveResult2 instanceof PsiMethod) {
-      final PsiMethod method1 = (PsiMethod)resolveResult1;
-      final PsiMethod method2 = (PsiMethod)resolveResult2;
-      if (ArrayUtil.find(method1.findSuperMethods(), method2) >= 0) return true;
-      if (ArrayUtil.find(method2.findSuperMethods(), method1) >= 0) return true;
-
-      if (method1.getName().equals(method2.getName())) {
-        PsiClass class2 = method2.getContainingClass();
-        if (qualifier2 instanceof PsiReferenceExpression) {
-          final PsiType type = ((PsiReferenceExpression)qualifier2).getType();
-          if (type instanceof PsiClassType){
-            final PsiClass resolvedClass = PsiUtil.resolveClassInType(type);
-            if (!(resolvedClass instanceof PsiTypeParameter)) {
-              class2 = resolvedClass;
-            }
-          }
-        }
-
-        if (class2 != null && PsiUtil.isAccessible(method1, class2, null)) {
-          final PsiMethod[] methods = class2.getAllMethods();
-          if (ArrayUtil.find(methods, method1) != -1) return true;
-        }
-      }
-      return false;
-    }
-    else {
-      return false;
-    }
-  }
-
-  private static boolean isUnder(PsiElement element, List<PsiElement> parents) {
-    if (element == null) return false;
-    for (final PsiElement parent : parents) {
-      if (PsiTreeUtil.isAncestor(parent, element, false)) return true;
-    }
-    return false;
-  }
-
-  private static PsiElement[] getFilteredChildren(PsiElement element1) {
-    PsiElement[] children1 = element1.getChildren();
-    ArrayList<PsiElement> array = new ArrayList<PsiElement>();
-    for (PsiElement child : children1) {
-      if (!(child instanceof PsiWhiteSpace) && !(child instanceof PsiComment)) {
-        if (child instanceof PsiBlockStatement) {
-          Collections.addAll(array, getFilteredChildren(child));
-          continue;
-        } else if (child instanceof PsiCodeBlock) {
-          final PsiStatement[] statements = ((PsiCodeBlock)child).getStatements();
-          if (statements.length == 1) {
-            array.add(statements[0]);
-            continue;
-          }
-        }
-        array.add(child);
-      }
-    }
-    return PsiUtilBase.toPsiElementArray(array);
-  }
-
-}
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ExpressionReturnValue.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/ExpressionReturnValue.java
deleted file mode 100644
index d8555bd..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ExpressionReturnValue.java
+++ /dev/null
@@ -1,54 +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.refactoring.util.duplicates;
-
-import com.intellij.codeInsight.PsiEquivalenceUtil;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.util.IncorrectOperationException;
-
-/**
- * @author dsl
- */
-public class ExpressionReturnValue implements ReturnValue {
-  private final PsiExpression myExpression;
-
-  public ExpressionReturnValue(PsiExpression expression) {
-    myExpression = expression;
-  }
-
-  public PsiExpression getExpression() {
-    return myExpression;
-  }
-
-  public boolean isEquivalent(ReturnValue other) {
-    if (!(other instanceof ExpressionReturnValue)) return false;
-    return PsiEquivalenceUtil.areElementsEquivalent(myExpression, ((ExpressionReturnValue)other).myExpression);
-  }
-
-  public PsiStatement createReplacement(final PsiMethod extractedMethod, final PsiMethodCallExpression methodCallExpression)
-    throws IncorrectOperationException {
-    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(methodCallExpression.getProject()).getElementFactory();
-    final CodeStyleManager styleManager = CodeStyleManager.getInstance(methodCallExpression.getProject());
-    PsiExpressionStatement expressionStatement;
-    expressionStatement = (PsiExpressionStatement)elementFactory.createStatementFromText("x = y();", null);
-    expressionStatement = (PsiExpressionStatement)styleManager.reformat(expressionStatement);
-    final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)expressionStatement.getExpression();
-    assignmentExpression.getLExpression().replace(getExpression());
-    assignmentExpression.getRExpression().replace(methodCallExpression);
-    return expressionStatement;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/FieldReturnValue.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/FieldReturnValue.java
deleted file mode 100644
index 6ddb9e6..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/FieldReturnValue.java
+++ /dev/null
@@ -1,54 +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.refactoring.util.duplicates;
-
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.util.IncorrectOperationException;
-
-/**
- * @author dsl
- */
-public class FieldReturnValue implements ReturnValue {
-  private final PsiField myField;
-
-  public FieldReturnValue(PsiField psiField) {
-    myField = psiField;
-  }
-
-  public boolean isEquivalent(ReturnValue other) {
-    if (!(other instanceof FieldReturnValue)) return false;
-    return myField == ((FieldReturnValue)other).myField;
-  }
-
-  public PsiField getField() {
-    return myField;
-  }
-
-  public PsiStatement createReplacement(final PsiMethod extractedMethod, final PsiMethodCallExpression methodCallExpression) throws IncorrectOperationException {
-
-    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(methodCallExpression.getProject()).getElementFactory();
-    final CodeStyleManager styleManager = CodeStyleManager.getInstance(methodCallExpression.getProject());
-    PsiExpressionStatement expressionStatement;
-    expressionStatement = (PsiExpressionStatement)elementFactory.createStatementFromText("x = y();", null);
-    expressionStatement = (PsiExpressionStatement)styleManager.reformat(expressionStatement);
-    final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)expressionStatement.getExpression();
-    assignmentExpression.getLExpression().replace(elementFactory.createExpressionFromText(myField.getName(), myField));
-    assignmentExpression.getRExpression().replace(methodCallExpression);
-    return expressionStatement;
-
-  }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/GotoReturnValue.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/GotoReturnValue.java
deleted file mode 100644
index 7727411..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/GotoReturnValue.java
+++ /dev/null
@@ -1,45 +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.
- */
-
-/*
- * User: anna
- * Date: 24-Oct-2008
- */
-package com.intellij.refactoring.util.duplicates;
-
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.psi.util.TypeConversionUtil;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.Nullable;
-
-public abstract class GotoReturnValue implements ReturnValue {
-  @Nullable
-  public PsiStatement createReplacement(final PsiMethod extractedMethod, final PsiMethodCallExpression methodCallExpression) throws
-                                                                                                                             IncorrectOperationException {
-    if (!TypeConversionUtil.isBooleanType(extractedMethod.getReturnType())) return null;
-    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(methodCallExpression.getProject()).getElementFactory();
-    final PsiIfStatement statement = (PsiIfStatement)elementFactory.createStatementFromText(getGotoStatement(), null);
-    final PsiExpression condition = statement.getCondition();
-    assert condition != null;
-    condition.replace(methodCallExpression);
-    return (PsiStatement)CodeStyleManager.getInstance(statement.getManager().getProject()).reformat(statement);
-  }
-
-  @NonNls
-  public abstract String getGotoStatement();
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/Match.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/Match.java
deleted file mode 100644
index 2ba06af..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/Match.java
+++ /dev/null
@@ -1,510 +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.refactoring.util.duplicates;
-
-import com.intellij.codeInsight.PsiEquivalenceUtil;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Pair;
-import com.intellij.openapi.util.Ref;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.controlFlow.*;
-import com.intellij.psi.util.*;
-import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
-import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.containers.HashMap;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author dsl
- */
-public final class Match {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.util.duplicates.Match");
-  private final PsiElement myMatchStart;
-  private final PsiElement myMatchEnd;
-  private final Map<PsiVariable, List<PsiElement>> myParameterValues = new HashMap<PsiVariable, List<PsiElement>>();
-  private final Map<PsiVariable, ArrayList<PsiElement>> myParameterOccurrences = new HashMap<PsiVariable, ArrayList<PsiElement>>();
-  private final Map<PsiElement, PsiElement> myDeclarationCorrespondence = new HashMap<PsiElement, PsiElement>();
-  private ReturnValue myReturnValue = null;
-  private Ref<PsiExpression> myInstanceExpression = null;
-  private final Map<PsiVariable, PsiType> myChangedParams = new HashMap<PsiVariable, PsiType>();
-  private final boolean myIgnoreParameterTypes;
-
-  Match(PsiElement start, PsiElement end, boolean ignoreParameterTypes) {
-    LOG.assertTrue(start.getParent() == end.getParent());
-    myMatchStart = start;
-    myMatchEnd = end;
-    myIgnoreParameterTypes = ignoreParameterTypes;
-  }
-
-
-  public PsiElement getMatchStart() {
-    return myMatchStart;
-  }
-
-  public PsiElement getMatchEnd() {
-    return myMatchEnd;
-  }
-
-  @Nullable
-  public List<PsiElement> getParameterValues(PsiVariable parameter) {
-    return myParameterValues.get(parameter);
-  }
-
-  /**
-   * Returns either local variable declaration or expression
-   * @param outputParameter
-   * @return
-   */
-  public ReturnValue getOutputVariableValue(PsiVariable outputParameter) {
-    final PsiElement decl = myDeclarationCorrespondence.get(outputParameter);
-    if (decl instanceof PsiVariable) {
-      return new VariableReturnValue((PsiVariable)decl);
-    }
-    final List<PsiElement> parameterValue = getParameterValues(outputParameter);
-    if (parameterValue != null && parameterValue.size() == 1 && parameterValue.get(0) instanceof PsiExpression) {
-      return new ExpressionReturnValue((PsiExpression) parameterValue.get(0));
-    }
-    else {
-      return null;
-    }
-  }
-
-
-  boolean putParameter(Pair<PsiVariable, PsiType> parameter, PsiElement value) {
-    final PsiVariable psiVariable = parameter.first;
-
-    if (myDeclarationCorrespondence.get(psiVariable) == null) {
-      final boolean [] valueDependsOnReplacedScope = new boolean[1];
-      value.accept(new JavaRecursiveElementWalkingVisitor() {
-        @Override
-        public void visitReferenceExpression(final PsiReferenceExpression expression) {
-          super.visitReferenceExpression(expression);
-          final PsiElement resolved = expression.resolve();
-          if (resolved != null && Comparing.equal(resolved.getContainingFile(), getMatchEnd().getContainingFile())) {
-            final TextRange range = checkRange(resolved);
-            final TextRange startRange = checkRange(getMatchStart());
-            final TextRange endRange = checkRange(getMatchEnd());
-            if (startRange.getStartOffset() <= range.getStartOffset() && range.getEndOffset() <= endRange.getEndOffset()) {
-              valueDependsOnReplacedScope[0] = true;
-            }
-          }
-        }
-      });
-      if (valueDependsOnReplacedScope[0]) return false;
-    }
-
-    final List<PsiElement> currentValue = myParameterValues.get(psiVariable);
-    final boolean isVararg = psiVariable instanceof PsiParameter && ((PsiParameter)psiVariable).isVarArgs();
-    if (!(value instanceof PsiExpression)) return false;
-    final PsiType type = ((PsiExpression)value).getType();
-    final PsiType parameterType = parameter.second;
-    if (type == null) return false;
-    if (currentValue == null) {
-      if (parameterType instanceof PsiClassType && ((PsiClassType)parameterType).resolve() instanceof PsiTypeParameter) {
-        final PsiTypeParameter typeParameter = (PsiTypeParameter)((PsiClassType)parameterType).resolve();
-        LOG.assertTrue(typeParameter != null);
-        for (PsiClassType classType : typeParameter.getExtendsListTypes()) {
-          if (!classType.isAssignableFrom(type)) return false;
-        }
-      }
-      else {
-        if (isVararg) {
-          if (!((PsiEllipsisType)psiVariable.getType()).getComponentType().isAssignableFrom(type) && !((PsiEllipsisType)psiVariable.getType()).toArrayType().equals(type)) {
-            myChangedParams.put(psiVariable, new PsiEllipsisType(parameterType));
-          }
-        } else {
-          if (!myIgnoreParameterTypes && !parameterType.isAssignableFrom(type)) return false;  //todo
-        }
-      }
-      final List<PsiElement> values = new ArrayList<PsiElement>();
-      values.add(value);
-      myParameterValues.put(psiVariable, values);
-      final ArrayList<PsiElement> elements = new ArrayList<PsiElement>();
-      myParameterOccurrences.put(psiVariable, elements);
-      return true;
-    }
-    else {
-      for (PsiElement val : currentValue) {
-        if (!isVararg && !PsiEquivalenceUtil.areElementsEquivalent(val, value)) {
-          return false;
-        }
-      }
-      if (isVararg) {
-        if (!parameterType.isAssignableFrom(type)) return false;
-        if (!((PsiEllipsisType)psiVariable.getType()).toArrayType().equals(type)){
-          currentValue.add(value);
-        }
-      }
-      myParameterOccurrences.get(psiVariable).add(value);
-      return true;
-    }
-  }
-
-  public ReturnValue getReturnValue() {
-    return myReturnValue;
-  }
-
-  boolean registerReturnValue(ReturnValue returnValue) {
-    if (myReturnValue == null) {
-      myReturnValue = returnValue;
-      return true;
-    }
-    else {
-      return myReturnValue.isEquivalent(returnValue);
-    }
-  }
-
-  boolean registerInstanceExpression(PsiExpression instanceExpression, final PsiClass contextClass) {
-    if (myInstanceExpression == null) {
-      if (instanceExpression != null) {
-        final PsiType type = instanceExpression.getType();
-        if (!(type instanceof PsiClassType)) return false;
-        final PsiClass hisClass = ((PsiClassType) type).resolve();
-        if (hisClass == null || !InheritanceUtil.isInheritorOrSelf(hisClass, contextClass, true)) return false;
-      }
-      myInstanceExpression = Ref.create(instanceExpression);
-      return true;
-    }
-    else {
-      if (myInstanceExpression.get() == null) {
-        myInstanceExpression.set(instanceExpression);
-
-        return instanceExpression == null;
-      }
-      else {
-        if (instanceExpression != null) {
-          return PsiEquivalenceUtil.areElementsEquivalent(instanceExpression, myInstanceExpression.get());
-        }
-        else {
-          return myInstanceExpression.get() == null || myInstanceExpression.get() instanceof PsiThisExpression;
-        }
-      }
-    }
-  }
-
-  boolean putDeclarationCorrespondence(PsiElement patternDeclaration, @NotNull PsiElement matchDeclaration) {
-    PsiElement originalValue = myDeclarationCorrespondence.get(patternDeclaration);
-    if (originalValue == null) {
-      myDeclarationCorrespondence.put(patternDeclaration, matchDeclaration);
-      return true;
-    }
-    else {
-      return originalValue == matchDeclaration;
-    }
-  }
-
-  boolean areCorrespond(PsiElement patternDeclaration, PsiElement matchDeclaration) {
-    if (matchDeclaration == null || patternDeclaration == null) return false;
-    PsiElement originalValue = myDeclarationCorrespondence.get(patternDeclaration);
-    return originalValue == null || originalValue == matchDeclaration;
-  }
-
-  private PsiElement replaceWith(final PsiStatement statement) throws IncorrectOperationException {
-    final PsiElement matchStart = getMatchStart();
-    final PsiElement matchEnd = getMatchEnd();
-    final PsiElement element = matchStart.getParent().addBefore(statement, matchStart);
-    matchStart.getParent().deleteChildRange(matchStart, matchEnd);
-    return element;
-  }
-
-  public PsiElement replaceByStatement(final PsiMethod extractedMethod, final PsiMethodCallExpression methodCallExpression, final PsiVariable outputVariable) throws IncorrectOperationException {
-    PsiStatement statement = null;
-    if (outputVariable != null) {
-      ReturnValue returnValue = getOutputVariableValue(outputVariable);
-      if (returnValue == null && outputVariable instanceof PsiField) {
-        returnValue = new FieldReturnValue((PsiField)outputVariable);
-      }
-      if (returnValue == null) return null;
-      statement = returnValue.createReplacement(extractedMethod, methodCallExpression);
-    }
-    else if (getReturnValue() != null) {
-      statement = getReturnValue().createReplacement(extractedMethod, methodCallExpression);
-    }
-    if (statement == null) {
-      final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(methodCallExpression.getProject()).getElementFactory();
-      PsiExpressionStatement expressionStatement = (PsiExpressionStatement) elementFactory.createStatementFromText("x();", null);
-      final CodeStyleManager styleManager = CodeStyleManager.getInstance(methodCallExpression.getManager());
-      expressionStatement = (PsiExpressionStatement)styleManager.reformat(expressionStatement);
-      expressionStatement.getExpression().replace(methodCallExpression);
-      statement = expressionStatement;
-    }
-    return replaceWith(statement);
-  }
-
-  public PsiExpression getInstanceExpression() {
-    if (myInstanceExpression == null) {
-      return null;
-    }
-    else {
-      return myInstanceExpression.get();
-    }
-  }
-
-  public PsiElement replace(final PsiMethod extractedMethod, final PsiMethodCallExpression methodCallExpression, PsiVariable outputVariable) throws IncorrectOperationException {
-    declareLocalVariables();
-    if (getMatchStart() == getMatchEnd() && getMatchStart() instanceof PsiExpression) {
-      return replaceWithExpression(methodCallExpression);
-    }
-    else {
-      return replaceByStatement(extractedMethod, methodCallExpression, outputVariable);
-    }
-  }
-
-  private void declareLocalVariables() throws IncorrectOperationException {
-    final PsiElement codeFragment = ControlFlowUtil.findCodeFragment(getMatchStart());
-    try {
-      final Project project = getMatchStart().getProject();
-      final ControlFlow controlFlow = ControlFlowFactory.getInstance(project)
-          .getControlFlow(codeFragment, new LocalsControlFlowPolicy(codeFragment));
-      final int endOffset = controlFlow.getEndOffset(getMatchEnd());
-      final int startOffset = controlFlow.getStartOffset(getMatchStart());
-      final List<PsiVariable> usedVariables = ControlFlowUtil.getUsedVariables(controlFlow, endOffset, controlFlow.getSize());
-      Collection<ControlFlowUtil.VariableInfo> reassigned = ControlFlowUtil.getInitializedTwice(controlFlow, endOffset, controlFlow.getSize());
-      final Collection<PsiVariable> outVariables = ControlFlowUtil.getWrittenVariables(controlFlow, startOffset, endOffset, false);
-      for (PsiVariable variable : usedVariables) {
-        if (!outVariables.contains(variable)) {
-          final PsiIdentifier identifier = variable.getNameIdentifier();
-          if (identifier != null) {
-            final TextRange textRange = checkRange(identifier);
-            final TextRange startRange = checkRange(getMatchStart());
-            final TextRange endRange = checkRange(getMatchEnd());
-            if (textRange.getStartOffset() >= startRange.getStartOffset() && textRange.getEndOffset() <= endRange.getEndOffset()) {
-              final String name = variable.getName();
-              LOG.assertTrue(name != null);
-              PsiDeclarationStatement statement =
-                  JavaPsiFacade.getInstance(project).getElementFactory().createVariableDeclarationStatement(name, variable.getType(), null);
-              if (reassigned.contains(new ControlFlowUtil.VariableInfo(variable, null))) {
-                final PsiElement[] psiElements = statement.getDeclaredElements();
-                final PsiModifierList modifierList = ((PsiVariable)psiElements[0]).getModifierList();
-                LOG.assertTrue(modifierList != null);
-                modifierList.setModifierProperty(PsiModifier.FINAL, false);
-              }
-              getMatchStart().getParent().addBefore(statement, getMatchStart());
-            }
-          }
-        }
-      }
-    }
-    catch (AnalysisCanceledException e) {
-      //skip match
-    }
-  }
-
-  private static TextRange checkRange(final PsiElement element) {
-    final TextRange endRange = element.getTextRange();
-    LOG.assertTrue(endRange != null, element);
-    return endRange;
-  }
-
-  public PsiElement replaceWithExpression(final PsiExpression psiExpression) throws IncorrectOperationException {
-    final PsiElement matchStart = getMatchStart();
-    LOG.assertTrue(matchStart == getMatchEnd());
-    if (psiExpression instanceof PsiMethodCallExpression && matchStart instanceof PsiReferenceExpression && matchStart.getParent() instanceof PsiMethodCallExpression) {
-      return JavaCodeStyleManager.getInstance(matchStart.getProject()).shortenClassReferences(matchStart.replace(((PsiMethodCallExpression)psiExpression).getMethodExpression()));
-    }
-    return JavaCodeStyleManager.getInstance(matchStart.getProject()).shortenClassReferences(matchStart.replace(psiExpression));
-  }
-
-  TextRange getTextRange() {
-    final TextRange startRange = checkRange(getMatchStart());
-    final TextRange endRange = checkRange(getMatchEnd());
-    return new TextRange(startRange.getStartOffset(), endRange.getEndOffset());
-  }
-
-  @Nullable
-  public String getChangedSignature(final PsiMethod method, final boolean shouldBeStatic, String visibility) {
-    final PsiType returnType = getChangedReturnType(method);
-    if (!myChangedParams.isEmpty() || returnType != null) {
-      @NonNls StringBuilder buffer = new StringBuilder();
-      buffer.append(visibility);
-      if (buffer.length() > 0) {
-        buffer.append(" ");
-      }
-      if (shouldBeStatic) {
-        buffer.append("static ");
-      }
-      final PsiTypeParameterList typeParameterList = method.getTypeParameterList();
-      if (typeParameterList != null) {
-        buffer.append(typeParameterList.getText());
-        buffer.append(" ");
-      }
-
-      buffer.append(PsiFormatUtil.formatType(returnType != null ? returnType : method.getReturnType(), 0, PsiSubstitutor.EMPTY));
-      buffer.append(" ");
-      buffer.append(method.getName());
-      buffer.append("(");
-      int count = 0;
-      final String INDENT = "    ";
-      final ArrayList<ParameterInfoImpl> params = patchParams(method);
-      for (ParameterInfoImpl param : params) {
-        String typeText = param.getTypeText();
-        if (count > 0) {
-          buffer.append(",");
-        }
-        buffer.append("\n");
-        buffer.append(INDENT);
-        buffer.append(typeText);
-        buffer.append(" ");
-        buffer.append(param.getName());
-        count++;
-      }
-
-      if (count > 0) {
-        buffer.append("\n");
-      }
-      buffer.append(")");
-      final PsiClassType[] exceptions = method.getThrowsList().getReferencedTypes();
-      if (exceptions.length > 0) {
-        buffer.append("\n");
-        buffer.append("throws\n");
-        for (PsiType exception : exceptions) {
-          buffer.append(INDENT);
-          buffer.append(PsiFormatUtil.formatType(exception, 0, PsiSubstitutor.EMPTY));
-          buffer.append("\n");
-        }
-      }
-      return buffer.toString();
-    }
-    return null;
-  }
-
-  public void changeSignature(final PsiMethod psiMethod) {
-    final PsiType expressionType = getChangedReturnType(psiMethod);
-    if (expressionType == null && myChangedParams.isEmpty()) return;
-    final ArrayList<ParameterInfoImpl> newParameters = patchParams(psiMethod);
-    final ChangeSignatureProcessor csp = new ChangeSignatureProcessor(psiMethod.getProject(), psiMethod, false, null, psiMethod.getName(),
-                                                                      expressionType != null ? expressionType : psiMethod.getReturnType(),
-                                                                      newParameters.toArray(new ParameterInfoImpl[newParameters.size()]));
-
-    csp.run();
-  }
-
-  @Nullable
-  private PsiType getChangedReturnType(final PsiMethod psiMethod) {
-    final PsiType returnType = psiMethod.getReturnType();
-    if (returnType != null) {
-      PsiElement parent = getMatchEnd().getParent();
-
-      if (parent instanceof PsiExpression) {
-        if (parent instanceof PsiMethodCallExpression) {
-          JavaResolveResult result = ((PsiMethodCallExpression)parent).resolveMethodGenerics();
-          final PsiMethod method = (PsiMethod)result.getElement();
-          if (method != null) {
-            PsiType type = method.getReturnType();
-            if (type != null) {
-              type = result.getSubstitutor().substitute(type);
-              if (weakerType(psiMethod, returnType, type)) {
-                return type;
-              }
-            }
-          }
-        }
-        else if (parent instanceof PsiReferenceExpression) {
-          final JavaResolveResult result = ((PsiReferenceExpression)parent).advancedResolve(false);
-          final PsiElement element = result.getElement();
-          if (element instanceof PsiMember) {
-            final PsiClass psiClass = ((PsiMember)element).getContainingClass();
-            if (psiClass != null && psiClass.isPhysical()) {
-              final JavaPsiFacade facade = JavaPsiFacade.getInstance(parent.getProject());
-              final PsiClassType expressionType = facade.getElementFactory().createType(psiClass, result.getSubstitutor());
-              if (weakerType(psiMethod, returnType, expressionType)) {
-                return expressionType;
-              }
-            }
-          }
-        }
-      }
-      else if (parent instanceof PsiExpressionList) {
-        final PsiExpression[] expressions = ((PsiExpressionList)parent).getExpressions();
-        final PsiElement call = parent.getParent();
-        if (call instanceof PsiMethodCallExpression) {
-          final JavaResolveResult result = ((PsiMethodCallExpression)call).resolveMethodGenerics();
-          final PsiMethod method = (PsiMethod)result.getElement();
-          if (method != null) {
-            final int idx = ArrayUtil.find(expressions, getMatchEnd());
-            final PsiParameter[] psiParameters = method.getParameterList().getParameters();
-            if (idx >= 0 && idx < psiParameters.length) {
-              PsiType type = result.getSubstitutor().substitute(psiParameters[idx].getType());
-              if (type instanceof PsiEllipsisType) {
-                type = ((PsiEllipsisType)type).getComponentType();
-              }
-              if (weakerType(psiMethod, returnType, type)){
-                return type;
-              }
-            }
-          }
-        }
-      }
-      else if (parent instanceof PsiLocalVariable) {
-        final PsiType localVariableType = ((PsiLocalVariable)parent).getType();
-        if (weakerType(psiMethod, returnType, localVariableType)) return localVariableType;
-      }
-      else if (parent instanceof PsiReturnStatement) {
-        final PsiMethod replacedMethod = PsiTreeUtil.getParentOfType(parent, PsiMethod.class);
-        LOG.assertTrue(replacedMethod != null);
-        final PsiType replacedMethodReturnType = replacedMethod.getReturnType();
-        if (weakerType(psiMethod, returnType, replacedMethodReturnType)) {
-          return replacedMethodReturnType;
-        }
-      }
-
-    }
-    return null;
-  }
-
-  private static boolean weakerType(final PsiMethod psiMethod, final PsiType returnType, final PsiType currentType) {
-    final PsiTypeParameter[] typeParameters = psiMethod.getTypeParameters();
-    final PsiSubstitutor substitutor =
-        JavaPsiFacade.getInstance(psiMethod.getProject()).getResolveHelper().inferTypeArguments(typeParameters, new PsiType[]{returnType}, new PsiType[]{currentType}, PsiUtil.getLanguageLevel(psiMethod));
-
-    return !TypeConversionUtil.isAssignable(currentType, substitutor.substitute(returnType));
-  }
-
-  private ArrayList<ParameterInfoImpl> patchParams(final PsiMethod psiMethod) {
-    final ArrayList<ParameterInfoImpl> newParameters = new ArrayList<ParameterInfoImpl>();
-    final PsiParameter[] oldParameters = psiMethod.getParameterList().getParameters();
-    for (int i = 0; i < oldParameters.length; i++) {
-      final PsiParameter oldParameter = oldParameters[i];
-      PsiType type = oldParameter.getType();
-      for (PsiVariable variable : myChangedParams.keySet()) {
-        if (PsiEquivalenceUtil.areElementsEquivalent(variable, oldParameter)) {
-          type = myChangedParams.get(variable);
-          break;
-        }
-      }
-      newParameters.add(new ParameterInfoImpl(i, oldParameter.getName(), type));
-    }
-    return newParameters;
-  }
-
-  public PsiFile getFile() {
-    return getMatchStart().getContainingFile();
-  }
-}
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/MatchUtil.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/MatchUtil.java
new file mode 100644
index 0000000..7c88fc1
--- /dev/null
+++ b/java/java-impl/src/com/intellij/refactoring/util/duplicates/MatchUtil.java
@@ -0,0 +1,116 @@
+/*
+ * 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.duplicates;
+
+import com.intellij.codeInsight.PsiEquivalenceUtil;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiFormatUtil;
+import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
+import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class MatchUtil {
+  @Nullable
+  public static String getChangedSignature(Match match, final PsiMethod method, final boolean shouldBeStatic, String visibility) {
+    final PsiType returnType = match.getChangedReturnType(method);
+    if (!match.myChangedParams.isEmpty() || returnType != null) {
+      @NonNls StringBuilder buffer = new StringBuilder();
+      buffer.append(visibility);
+      if (buffer.length() > 0) {
+        buffer.append(" ");
+      }
+      if (shouldBeStatic) {
+        buffer.append("static ");
+      }
+      final PsiTypeParameterList typeParameterList = method.getTypeParameterList();
+      if (typeParameterList != null) {
+        buffer.append(typeParameterList.getText());
+        buffer.append(" ");
+      }
+
+      buffer.append(PsiFormatUtil.formatType(returnType != null ? returnType : method.getReturnType(), 0, PsiSubstitutor.EMPTY));
+      buffer.append(" ");
+      buffer.append(method.getName());
+      buffer.append("(");
+      int count = 0;
+      final String INDENT = "    ";
+      final List<ParameterInfoImpl> params = patchParams(match.myChangedParams, method);
+      for (ParameterInfoImpl param : params) {
+        String typeText = param.getTypeText();
+        if (count > 0) {
+          buffer.append(",");
+        }
+        buffer.append("\n");
+        buffer.append(INDENT);
+        buffer.append(typeText);
+        buffer.append(" ");
+        buffer.append(param.getName());
+        count++;
+      }
+
+      if (count > 0) {
+        buffer.append("\n");
+      }
+      buffer.append(")");
+      final PsiClassType[] exceptions = method.getThrowsList().getReferencedTypes();
+      if (exceptions.length > 0) {
+        buffer.append("\n");
+        buffer.append("throws\n");
+        for (PsiType exception : exceptions) {
+          buffer.append(INDENT);
+          buffer.append(PsiFormatUtil.formatType(exception, 0, PsiSubstitutor.EMPTY));
+          buffer.append("\n");
+        }
+      }
+      return buffer.toString();
+    }
+    return null;
+  }
+
+  public static void changeSignature(@NotNull Match match, @NotNull PsiMethod psiMethod) {
+    final PsiType expressionType = match.getChangedReturnType(psiMethod);
+    if (expressionType == null && match.myChangedParams.isEmpty()) return;
+    final List<ParameterInfoImpl> newParameters = patchParams(match.myChangedParams, psiMethod);
+    final ChangeSignatureProcessor csp = new ChangeSignatureProcessor(psiMethod.getProject(), psiMethod, false, null, psiMethod.getName(),
+                                                                      expressionType != null ? expressionType : psiMethod.getReturnType(),
+                                                                      newParameters.toArray(new ParameterInfoImpl[newParameters.size()]));
+
+    csp.run();
+  }
+
+  public static List<ParameterInfoImpl> patchParams(Map<PsiVariable, PsiType> changedParams, final PsiMethod psiMethod) {
+    final ArrayList<ParameterInfoImpl> newParameters = new ArrayList<ParameterInfoImpl>();
+    final PsiParameter[] oldParameters = psiMethod.getParameterList().getParameters();
+    for (int i = 0; i < oldParameters.length; i++) {
+      final PsiParameter oldParameter = oldParameters[i];
+      PsiType type = oldParameter.getType();
+      for (PsiVariable variable : changedParams.keySet()) {
+        if (PsiEquivalenceUtil.areElementsEquivalent(variable, oldParameter)) {
+          type = changedParams.get(variable);
+          break;
+        }
+      }
+      newParameters.add(new ParameterInfoImpl(i, oldParameter.getName(), type));
+    }
+    return newParameters;
+  }
+}
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 6476aa4..7686126 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
@@ -48,7 +48,7 @@
 
   @Override
   public PsiElement processMatch(Match match) throws IncorrectOperationException {
-    match.changeSignature(myMethod);
+    MatchUtil.changeSignature(match, myMethod);
     final PsiClass containingClass = myMethod.getContainingClass();
     if (isEssentialStaticContextAbsent(match)) {
       PsiUtil.setModifierProperty(myMethod, PsiModifier.STATIC, true);
@@ -159,7 +159,8 @@
     final PsiElement matchStart = match.getMatchStart();
     String visibility = VisibilityUtil.getPossibleVisibility(myMethod, matchStart);
     final boolean shouldBeStatic = isEssentialStaticContextAbsent(match);
-    final String signature = match.getChangedSignature(myMethod, myMethod.hasModifierProperty(PsiModifier.STATIC) || shouldBeStatic, visibility);
+    final String signature = MatchUtil
+      .getChangedSignature(match, myMethod, myMethod.hasModifierProperty(PsiModifier.STATIC) || shouldBeStatic, visibility);
     if (signature != null) {
       return RefactoringBundle.message("replace.this.code.fragment.and.change.signature", signature);
     }
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ReturnStatementReturnValue.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/ReturnStatementReturnValue.java
deleted file mode 100644
index ea66c86..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ReturnStatementReturnValue.java
+++ /dev/null
@@ -1,42 +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.refactoring.util.duplicates;
-
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.util.IncorrectOperationException;
-
-/**
- * @author dsl
- */
-public class ReturnStatementReturnValue implements ReturnValue {
-  public static final ReturnStatementReturnValue INSTANCE = new ReturnStatementReturnValue();
-
-  private ReturnStatementReturnValue() {}
-
-  public boolean isEquivalent(ReturnValue other) {
-    return other instanceof ReturnStatementReturnValue;
-  }
-
-  public PsiStatement createReplacement(final PsiMethod extractedMethod, final PsiMethodCallExpression methodCallExpression) throws IncorrectOperationException {
-    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(methodCallExpression.getProject()).getElementFactory();
-    final CodeStyleManager styleManager = CodeStyleManager.getInstance(methodCallExpression.getProject());
-    PsiReturnStatement returnStatement = (PsiReturnStatement)elementFactory.createStatementFromText("return x;", null);
-    returnStatement = (PsiReturnStatement) styleManager.reformat(returnStatement);
-    returnStatement.getReturnValue().replace(methodCallExpression);
-    return returnStatement;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ReturnValue.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/ReturnValue.java
deleted file mode 100644
index 896ea60..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ReturnValue.java
+++ /dev/null
@@ -1,32 +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.refactoring.util.duplicates;
-
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiMethodCallExpression;
-import com.intellij.psi.PsiStatement;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * @author dsl
- */
-public interface ReturnValue {
-  boolean isEquivalent(ReturnValue other);
-
-  @Nullable
-  PsiStatement createReplacement(final PsiMethod extractedMethod, PsiMethodCallExpression methodCallExpression) throws IncorrectOperationException;
-}
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/VariableReturnValue.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/VariableReturnValue.java
deleted file mode 100644
index 75edb10..0000000
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/VariableReturnValue.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.refactoring.util.duplicates;
-
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.util.IncorrectOperationException;
-
-/**
- * @author dsl
- */
-public class VariableReturnValue implements ReturnValue {
-  private final PsiVariable myVariable;
-
-  public VariableReturnValue(PsiVariable variable) {
-    myVariable = variable;
-  }
-
-  public boolean isEquivalent(ReturnValue other) {
-    if (!(other instanceof VariableReturnValue)) return false;
-    return myVariable == ((VariableReturnValue)other).myVariable;
-  }
-
-  public PsiVariable getVariable() {
-    return myVariable;
-  }
-
-  public PsiStatement createReplacement(final PsiMethod extractedMethod, final PsiMethodCallExpression methodCallExpression) throws IncorrectOperationException {
-    final PsiDeclarationStatement statement;
-
-    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(methodCallExpression.getProject()).getElementFactory();
-    final CodeStyleManager styleManager = CodeStyleManager.getInstance(methodCallExpression.getProject());
-    statement = (PsiDeclarationStatement)styleManager.reformat(
-      elementFactory.createVariableDeclarationStatement(myVariable.getName(), myVariable.getType(), methodCallExpression)
-    );
-    ((PsiVariable)statement.getDeclaredElements()[0]).getModifierList().replace(myVariable.getModifierList());
-    return statement;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java
index 7e9b37f..b967928 100644
--- a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java
@@ -30,11 +30,11 @@
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.search.searches.OverridingMethodsSearch;
 import com.intellij.psi.search.searches.ReferencesSearch;
+import com.intellij.psi.util.PropertyUtil;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.TypeConversionUtil;
 import com.intellij.refactoring.MoveDestination;
 import com.intellij.refactoring.RefactorJBundle;
-import com.intellij.refactoring.psi.PropertyUtils;
 import com.intellij.refactoring.psi.TypeParametersVisitor;
 import com.intellij.refactoring.util.FixableUsageInfo;
 import com.intellij.refactoring.util.FixableUsagesRefactoringProcessor;
@@ -111,7 +111,7 @@
         return unboxedType.getCanonicalText() + "Value()";
       }
 
-      final PsiMethod getter = PropertyUtils.findGetterForField(myDelegateField);
+      final PsiMethod getter = PropertyUtil.findGetterForField(myDelegateField);
       return getter != null ? getter.getName() : "";
     }
     return "";
diff --git a/java/java-impl/src/com/intellij/testIntegration/BaseGenerateTestSupportMethodAction.java b/java/java-impl/src/com/intellij/testIntegration/BaseGenerateTestSupportMethodAction.java
index e9f0888..05207ff 100644
--- a/java/java-impl/src/com/intellij/testIntegration/BaseGenerateTestSupportMethodAction.java
+++ b/java/java-impl/src/com/intellij/testIntegration/BaseGenerateTestSupportMethodAction.java
@@ -16,7 +16,7 @@
 package com.intellij.testIntegration;
 
 import com.intellij.codeInsight.CodeInsightActionHandler;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.generation.GenerateMembersUtil;
 import com.intellij.codeInsight.generation.OverrideImplementUtil;
 import com.intellij.codeInsight.generation.PsiGenerationInfo;
@@ -172,7 +172,7 @@
       GenerateMembersUtil.insertMembersAtOffset(file, offset, Collections.singletonList(info));
 
       final PsiMethod member = info.getPsiMember();
-      return member != null ? CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(member) : null;
+      return member != null ? CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(member) : null;
     }
 
     private static int findOffsetToInsertMethodTo(Editor editor, PsiFile file) {
diff --git a/java/java-impl/src/com/intellij/ui/JavaReferenceEditorUtil.java b/java/java-impl/src/com/intellij/ui/JavaReferenceEditorUtil.java
index eae2183..b5323ad 100644
--- a/java/java-impl/src/com/intellij/ui/JavaReferenceEditorUtil.java
+++ b/java/java-impl/src/com/intellij/ui/JavaReferenceEditorUtil.java
@@ -43,11 +43,21 @@
   }
 
   @Nullable
-  public static Document createDocument(final String text, Project project, boolean isClassesAccepted) {
+  public static Document createDocument(final String text,
+                                        Project project,
+                                        boolean isClassesAccepted) {
+    return createDocument(text, project, isClassesAccepted, JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE);
+  }
+
+  @Nullable
+  public static Document createDocument(final String text,
+                                        Project project,
+                                        boolean isClassesAccepted, 
+                                        JavaCodeFragment.VisibilityChecker visibilityChecker) {
     final PsiPackage defaultPackage = JavaPsiFacade.getInstance(project).findPackage("");
     final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(project);
     final JavaCodeFragment fragment = factory.createReferenceCodeFragment(text, defaultPackage, true, isClassesAccepted);
-    fragment.setVisibilityChecker(JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE);
+    fragment.setVisibilityChecker(visibilityChecker);
     return PsiDocumentManager.getInstance(project).getDocument(fragment);
   }
 
diff --git a/java/java-impl/src/com/intellij/ui/ReferenceEditorComboWithBrowseButton.java b/java/java-impl/src/com/intellij/ui/ReferenceEditorComboWithBrowseButton.java
index 718a8c2..e86cbb5 100644
--- a/java/java-impl/src/com/intellij/ui/ReferenceEditorComboWithBrowseButton.java
+++ b/java/java-impl/src/com/intellij/ui/ReferenceEditorComboWithBrowseButton.java
@@ -43,7 +43,7 @@
                                               @NotNull final Project project,
                                               boolean toAcceptClasses,
                                               final JavaCodeFragment.VisibilityChecker visibilityChecker, final String recentsKey) {
-    super(new EditorComboBox(createDocument(StringUtil.isEmpty(text) ? "" : text, project, toAcceptClasses, visibilityChecker), project, StdFileTypes.JAVA),
+    super(new EditorComboBox(JavaReferenceEditorUtil.createDocument(StringUtil.isEmpty(text) ? "" : text, project, toAcceptClasses, visibilityChecker), project, StdFileTypes.JAVA),
           browseActionListener);
     final List<String> recentEntries = RecentsManager.getInstance(project).getRecentEntries(recentsKey);
     if (recentEntries != null) {
@@ -54,16 +54,6 @@
     }
   }
 
-  private static Document createDocument(final String text,
-                                         Project project,
-                                         boolean isClassesAccepted, 
-                                         final JavaCodeFragment.VisibilityChecker visibilityChecker) {
-    PsiPackage defaultPackage = JavaPsiFacade.getInstance(project).findPackage("");
-    final JavaCodeFragment fragment = JavaCodeFragmentFactory.getInstance(project).createReferenceCodeFragment(text, defaultPackage, true, isClassesAccepted);
-    fragment.setVisibilityChecker(visibilityChecker);
-    return PsiDocumentManager.getInstance(project).getDocument(fragment);
-  }
-
   public String getText(){
     return getChildComponent().getText().trim();
   }
diff --git a/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java b/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java
index 4c51caf..2627fd2 100644
--- a/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java
+++ b/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java
@@ -213,6 +213,10 @@
     return new Action[]{createNormalizeTextAction(), getOKAction(), getCancelAction(), getHelpAction()};
   }
 
+  public JComponent getPreferredFocusedComponent() {
+    return getRootPane().getDefaultButton();
+  }
+
   private void createLogFileChooser() {
     myLogFile = new TextFieldWithHistory();
     JPanel panel = GuiUtils.constructFieldWithBrowseButton(myLogFile, new ActionListener() {
@@ -417,10 +421,6 @@
     return "#com.intellij.unscramble.UnscrambleDialog";
   }
 
-  public JComponent getPreferredFocusedComponent() {
-    return myStacktraceEditorPanel.getEditorComponent();
-  }
-
   @Nullable
   private static String getExceptionName(String unscrambledTrace) {
     @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")