// !! - 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) return false;
   return true;
 }
  private IExpressionFragment getSelectedExpression() throws JavaScriptModelException {
    if (fSelectedExpression != null) return fSelectedExpression;

    IASTFragment selectedFragment =
        ASTFragmentFactory.createFragmentForSourceRange(
            new SourceRange(fSelectionStart, fSelectionLength), fCuRewrite.getRoot(), fCu);

    if (selectedFragment instanceof IExpressionFragment
        && !Checks.isInsideJavadoc(selectedFragment.getAssociatedNode())) {
      fSelectedExpression = (IExpressionFragment) selectedFragment;
    }

    return fSelectedExpression;
  }