blob: d9c40ea9fa25020b293bc4aad3bd48907f6eb788 [file] [log] [blame]
Jooyung Han888c5bc2020-12-22 17:28:47 +09001/*
2 * Copyright (C) 2020, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include <map>
Jooyung Han808a2a02020-12-28 16:46:54 +090019#include <stack>
Jooyung Han888c5bc2020-12-22 17:28:47 +090020#include <string>
21#include <vector>
22
Jooyung Han808a2a02020-12-28 16:46:54 +090023#include <android-base/scopeguard.h>
24#include <android-base/strings.h>
25
Jiyong Parkd9113322020-12-31 03:20:33 +090026class AidlDocument;
Jooyung Han888c5bc2020-12-22 17:28:47 +090027class AidlLocation;
28class AidlErrorLog;
29
30namespace android {
31namespace aidl {
32
33enum class DiagnosticSeverity {
34 DISABLED,
35 WARNING,
36 ERROR,
37};
38
39enum class DiagnosticID {
40#define DIAG(ENUM, NAME, ENABLED) ENUM,
Jooyung Han888c5bc2020-12-22 17:28:47 +090041#include "diagnostics.inc"
42#undef DIAG
43};
44
Jooyung Han808a2a02020-12-28 16:46:54 +090045class DiagnosticMapping {
46 public:
47 DiagnosticSeverity Severity(DiagnosticID id) const;
48 void Severity(DiagnosticID id, DiagnosticSeverity severity);
49
50 private:
51 std::map<DiagnosticID, DiagnosticSeverity> mapping_;
52};
53
Jooyung Han888c5bc2020-12-22 17:28:47 +090054struct DiagnosticOption {
55 DiagnosticID id;
56 const std::string name;
57 bool default_enabled;
58};
59
60extern const std::map<std::string, DiagnosticOption> kAllDiagnostics;
Jooyung Han3557e482020-12-24 05:11:15 +090061
Jooyung Han7be55792020-12-29 14:50:13 +090062// relying on Argument-dependent lookup
63std::string to_string(DiagnosticID id);
Jooyung Han888c5bc2020-12-22 17:28:47 +090064
Jiyong Parkd9113322020-12-31 03:20:33 +090065bool Diagnose(const AidlDocument& doc, const DiagnosticMapping& mapping);
66
Jooyung Han888c5bc2020-12-22 17:28:47 +090067} // namespace aidl
Jiyong Parkd9113322020-12-31 03:20:33 +090068} // namespace android