// !! - like one in ExtractTempRefactoring
 private static boolean canReplace(IASTFragment fragment) {
   ASTNode node = fragment.getAssociatedNode();
   ASTNode parent = node.getParent();
   if (parent instanceof VariableDeclarationFragment) {
     VariableDeclarationFragment vdf = (VariableDeclarationFragment) parent;
     if (node.equals(vdf.getName())) return false;
   }
   if (parent instanceof ExpressionStatement) return false;
   if (parent instanceof SwitchCase) {
     if (node instanceof Name) {
       Name name = (Name) node;
       ITypeBinding typeBinding = name.resolveTypeBinding();
       if (typeBinding != null) {
         return !typeBinding.isEnum();
       }
     }
   }
   return true;
 }
  private int evaluateFieldModifiers(ASTNode newTypeDecl) {
    if (fSenderBinding.isAnnotation()) {
      return 0;
    }
    if (fSenderBinding.isInterface()) {
      // for interface members copy the modifiers from an existing field
      FieldDeclaration[] fieldDecls = ((TypeDeclaration) newTypeDecl).getFields();
      if (fieldDecls.length > 0) {
        return fieldDecls[0].getModifiers();
      }
      return 0;
    }
    int modifiers = 0;

    if (fVariableKind == CONST_FIELD) {
      modifiers |= Modifier.FINAL | Modifier.STATIC;
    } else {
      ASTNode parent = fOriginalNode.getParent();
      if (parent instanceof QualifiedName) {
        IBinding qualifierBinding = ((QualifiedName) parent).getQualifier().resolveBinding();
        if (qualifierBinding instanceof ITypeBinding) {
          modifiers |= Modifier.STATIC;
        }
      } else if (ASTResolving.isInStaticContext(fOriginalNode)) {
        modifiers |= Modifier.STATIC;
      }
    }
    ASTNode node = ASTResolving.findParentType(fOriginalNode, true);
    if (newTypeDecl.equals(node)) {
      modifiers |= Modifier.PRIVATE;
    } else if (node instanceof AnonymousClassDeclaration) {
      modifiers |= Modifier.PROTECTED;
    } else {
      modifiers |= Modifier.PUBLIC;
    }

    return modifiers;
  }