/* bd is a static field declaration or static initializer */
  private static boolean depends(IExpressionFragment selected, BodyDeclaration bd) {
    /* We currently consider selected to depend on bd only if db includes a declaration
     * of a static field on which selected depends.
     *
     * A more accurate strategy might be to also check if bd contains (or is) a
     * static initializer containing code which changes the value of a static field on
     * which selected depends.  However, if a static is written to multiple times within
     * during class initialization, it is difficult to predict which value should be used.
     * This would depend on which value is used by expressions instances for which the new
     * constant will be substituted, and there may be many of these; in each, the
     * static field in question may have taken on a different value (if some of these uses
     * occur within static initializers).
     */

    if (bd instanceof FieldDeclaration) {
      FieldDeclaration fieldDecl = (FieldDeclaration) bd;
      for (Iterator<VariableDeclarationFragment> fragments = fieldDecl.fragments().iterator();
          fragments.hasNext(); ) {
        VariableDeclarationFragment fragment = fragments.next();
        SimpleName staticFieldName = fragment.getName();
        if (selected.getSubFragmentsMatching(
                    ASTFragmentFactory.createFragmentForFullSubtree(staticFieldName))
                .length
            != 0) return true;
      }
    }
    return false;
  }
 private IASTFragment[] getFragmentsToReplace() throws JavaModelException {
   List<IASTFragment> toReplace = new ArrayList<>();
   if (fReplaceAllOccurrences) {
     Iterator<ASTNode> replacementScope = getReplacementScope();
     while (replacementScope.hasNext()) {
       ASTNode scope = replacementScope.next();
       IASTFragment[] allMatches =
           ASTFragmentFactory.createFragmentForFullSubtree(scope)
               .getSubFragmentsMatching(getSelectedExpression());
       IASTFragment[] replaceableMatches = retainOnlyReplacableMatches(allMatches);
       for (int i = 0; i < replaceableMatches.length; i++) toReplace.add(replaceableMatches[i]);
     }
   } else if (canReplace(getSelectedExpression())) toReplace.add(getSelectedExpression());
   return toReplace.toArray(new IASTFragment[toReplace.size()]);
 }