private RefactoringStatus checkExpressionFragmentIsRValue() throws JavaScriptModelException {
   /* Moved this functionality to Checks, to allow sharing with
   ExtractTempRefactoring, others */
   switch (Checks.checkExpressionIsRValue(getSelectedExpression().getAssociatedExpression())) {
     case Checks.NOT_RVALUE_MISC:
       return RefactoringStatus.createStatus(
           RefactoringStatus.FATAL,
           RefactoringCoreMessages.ExtractConstantRefactoring_select_expression,
           null,
           Corext.getPluginId(),
           RefactoringStatusCodes.EXPRESSION_NOT_RVALUE,
           null);
     case Checks.NOT_RVALUE_VOID:
       return RefactoringStatus.createStatus(
           RefactoringStatus.FATAL,
           RefactoringCoreMessages.ExtractConstantRefactoring_no_void,
           null,
           Corext.getPluginId(),
           RefactoringStatusCodes.EXPRESSION_NOT_RVALUE_VOID,
           null);
     case Checks.IS_RVALUE:
       return new RefactoringStatus();
     default:
       Assert.isTrue(false);
       return null;
   }
 }
  public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
    try {
      pm.beginTask("", 7); // $NON-NLS-1$

      RefactoringStatus result = Checks.validateEdit(fCu, getValidationContext());
      if (result.hasFatalError()) return result;
      pm.worked(1);

      if (fCuRewrite == null) {
        JavaScriptUnit cuNode =
            RefactoringASTParser.parseWithASTProvider(fCu, true, new SubProgressMonitor(pm, 3));
        fCuRewrite = new CompilationUnitRewrite(fCu, cuNode);
      } else {
        pm.worked(3);
      }
      result.merge(checkSelection(new SubProgressMonitor(pm, 3)));

      if (result.hasFatalError()) return result;

      if (isLiteralNodeSelected()) fReplaceAllOccurrences = false;

      return result;
    } finally {
      pm.done();
    }
  }
 /**
  * This method performs checks on the constant name which are quick enough to be performed every
  * time the ui input component contents are changed.
  *
  * @return return the resulting status
  * @throws JavaScriptModelException thrown when the operation could not be executed
  */
 public RefactoringStatus checkConstantNameOnChange() throws JavaScriptModelException {
   if (Arrays.asList(getExcludedVariableNames()).contains(fConstantName))
     return RefactoringStatus.createErrorStatus(
         Messages.format(
             RefactoringCoreMessages.ExtractConstantRefactoring_another_variable,
             getConstantName()));
   return Checks.checkConstantName(getConstantName());
 }
  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;
  }