code: public static VariableElement getVariableElement(Expression node) {
      node = trimParentheses(node);
      switch (node.getKind()) {
        case FIELD_ACCESS:
          return ((FieldAccess) node).getVariableElement();
        case SUPER_FIELD_ACCESS:
          return ((SuperFieldAccess) node).getVariableElement();
        case QUALIFIED_NAME:
        case SIMPLE_NAME:
          return getVariableElement((Name) node);
        default:
          return null;
      }
    }
docs: Gets a variable element for the given expression if the expression
  represents a variable. Returns null otherwise.