//
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

// LINT: LEGACY_NAMES

syntax = "proto2";

package zetasql;

option java_package = "com.google.zetasql";
option java_outer_classname = "DeprecationWarningProtos";

import "zetasql/public/error_location.proto";

// Contains information about a deprecation warning emitted by the
// analyzer. Currently attached to any absl::Status returned by
// AnalyzerOutput::deprecation_warnings().
message DeprecationWarning {

  enum Kind {
    // User code that switches on this enum must have a default case so
    // builds won't break if new enums get added.
    __Kind__switch_must_have_a_default__ = -1;

    UNKNOWN = 0;

    DEPRECATED_FUNCTION = 1;

    DEPRECATED_FUNCTION_SIGNATURE = 2;

    // proto.has_<field>() is not well-defined if 'proto' comes from a file with
    // proto3 syntax, but it is currently supported by the analyzer.
    PROTO3_FIELD_PRESENCE = 3;

    // TODO: when a new kind of warning is added, consider
    // integrating these complex query warnings.
    QUERY_TOO_COMPLEX = 4;

    // Indicates that the query used the anonymization option KAPPA.
    //
    // The option is deprecated in favor of the synonym MAX_GROUPS_CONTRIBUTED.
    DEPRECATED_ANONYMIZATION_OPTION_KAPPA = 5;
  }

  optional Kind kind = 1;

  // TODO: Consider adding more (per-kind) structured information here
  // to facilitate automated analysis of deprecation warnings. For now, working
  // with the absl::Status error messages seems sufficient.
}

// A non-absl::Status-based representation of a deprecation warning that can be
// stored in objects that can be stored in the resolved AST (e.g.,
// FunctionSignatures).
//
message FreestandingDeprecationWarning {
  optional string message = 1;
  optional string caret_string = 2;
  optional ErrorLocation error_location = 3;
  optional DeprecationWarning deprecation_warning = 4;
}
