public static EnumSet<GrIntroduceFieldSettings.Init> getApplicableInitPlaces(GrIntroduceContext context,
                                                                               boolean replaceAllOccurrences) {
    EnumSet<GrIntroduceFieldSettings.Init> result = EnumSet.noneOf(GrIntroduceFieldSettings.Init.class);

    if (!(context.getScope() instanceof GroovyScriptClass || context.getScope() instanceof GroovyFileBase)) {
      if (context.getExpression() != null ||
          context.getVar() != null && context.getVar().getInitializerGroovy() != null ||
          context.getStringPart() != null) {
        result.add(GrIntroduceFieldSettings.Init.FIELD_DECLARATION);
      }
      result.add(GrIntroduceFieldSettings.Init.CONSTRUCTOR);
    }

    PsiElement scope = context.getScope();
    if (scope instanceof GroovyScriptClass) scope = scope.getContainingFile();

    if (replaceAllOccurrences || context.getExpression() != null) {
      PsiElement[] occurrences = replaceAllOccurrences ? context.getOccurrences() : new PsiElement[]{context.getExpression()};
      PsiElement parent = PsiTreeUtil.findCommonParent(occurrences);
      PsiElement container = GrIntroduceHandlerBase.getEnclosingContainer(parent);
      if (container != null && PsiTreeUtil.isAncestor(scope, container, false)) {
        PsiElement anchor = GrIntroduceHandlerBase.findAnchor(occurrences, container);
        if (anchor != null) {
          result.add(GrIntroduceFieldSettings.Init.CUR_METHOD);
        }
      }
    }

    if (scope instanceof GrTypeDefinition && TestFrameworks.getInstance().isTestClass((PsiClass)scope)) {
      result.add(GrIntroduceFieldSettings.Init.SETUP_METHOD);
    }

    return result;
  }
public static EnumSet<GrIntroduceFieldSettings.Init> getApplicableInitPlaces(GrIntroduceContext context,
                                                                               boolean replaceAllOccurrences)