private void computeConstantDeclarationLocation() throws JavaScriptModelException {
    if (isDeclarationLocationComputed()) return;

    BodyDeclaration lastStaticDependency = null;
    Iterator decls = getBodyDeclarations();

    Assert.isTrue(decls.hasNext()); /* Admissible selected expressions must occur
		                                   within a body declaration.  Thus, the
		                                   class/interface in which such an expression occurs
		                                   must have at least one body declaration */

    while (decls.hasNext()) {
      BodyDeclaration decl = (BodyDeclaration) decls.next();

      int modifiers;
      if (decl instanceof FieldDeclaration) modifiers = ((FieldDeclaration) decl).getModifiers();
      else if (decl instanceof Initializer) modifiers = ((Initializer) decl).getModifiers();
      else {
        continue; /* this declaration is not a field declaration
                  or initializer, so the placement of the constant
                  declaration relative to it does not matter */
      }

      if (Modifier.isStatic(modifiers) && depends(getSelectedExpression(), decl))
        lastStaticDependency = decl;
    }

    if (lastStaticDependency == null) fInsertFirst = true;
    else fToInsertAfter = lastStaticDependency;
  }
  private static boolean isStaticFieldOrStaticInitializer(BodyDeclaration node) {
    if (node instanceof FunctionDeclaration || node instanceof AbstractTypeDeclaration)
      return false;

    int modifiers;
    if (node instanceof FieldDeclaration) {
      modifiers = ((FieldDeclaration) node).getModifiers();
    } else if (node instanceof Initializer) {
      modifiers = ((Initializer) node).getModifiers();
    } else {
      Assert.isTrue(false);
      return false;
    }

    if (!Modifier.isStatic(modifiers)) return false;

    return true;
  }
  /*
  * @see ASTVisitor#visit(Modifier)

  */
  public boolean visit(Modifier node) {
    this.fBuffer.append(node.getKeyword().toString());
    return false;
  }