Jooyung Han | 888c5bc | 2020-12-22 17:28:47 +0900 | [diff] [blame] | 1 | /* |
| 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 Han | 808a2a0 | 2020-12-28 16:46:54 +0900 | [diff] [blame] | 19 | #include <stack> |
Jooyung Han | 888c5bc | 2020-12-22 17:28:47 +0900 | [diff] [blame] | 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
Jooyung Han | 808a2a0 | 2020-12-28 16:46:54 +0900 | [diff] [blame] | 23 | #include <android-base/scopeguard.h> |
| 24 | #include <android-base/strings.h> |
| 25 | |
Jiyong Park | d911332 | 2020-12-31 03:20:33 +0900 | [diff] [blame] | 26 | class AidlDocument; |
Jooyung Han | 888c5bc | 2020-12-22 17:28:47 +0900 | [diff] [blame] | 27 | class AidlLocation; |
| 28 | class AidlErrorLog; |
| 29 | |
| 30 | namespace android { |
| 31 | namespace aidl { |
| 32 | |
| 33 | enum class DiagnosticSeverity { |
| 34 | DISABLED, |
| 35 | WARNING, |
| 36 | ERROR, |
| 37 | }; |
| 38 | |
| 39 | enum class DiagnosticID { |
| 40 | #define DIAG(ENUM, NAME, ENABLED) ENUM, |
Jooyung Han | 888c5bc | 2020-12-22 17:28:47 +0900 | [diff] [blame] | 41 | #include "diagnostics.inc" |
| 42 | #undef DIAG |
| 43 | }; |
| 44 | |
Jooyung Han | 808a2a0 | 2020-12-28 16:46:54 +0900 | [diff] [blame] | 45 | class 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 Han | 888c5bc | 2020-12-22 17:28:47 +0900 | [diff] [blame] | 54 | struct DiagnosticOption { |
| 55 | DiagnosticID id; |
| 56 | const std::string name; |
| 57 | bool default_enabled; |
| 58 | }; |
| 59 | |
| 60 | extern const std::map<std::string, DiagnosticOption> kAllDiagnostics; |
Jooyung Han | 3557e48 | 2020-12-24 05:11:15 +0900 | [diff] [blame] | 61 | |
Jooyung Han | 7be5579 | 2020-12-29 14:50:13 +0900 | [diff] [blame] | 62 | // relying on Argument-dependent lookup |
| 63 | std::string to_string(DiagnosticID id); |
Jooyung Han | 888c5bc | 2020-12-22 17:28:47 +0900 | [diff] [blame] | 64 | |
Jiyong Park | d911332 | 2020-12-31 03:20:33 +0900 | [diff] [blame] | 65 | bool Diagnose(const AidlDocument& doc, const DiagnosticMapping& mapping); |
| 66 | |
Jooyung Han | 888c5bc | 2020-12-22 17:28:47 +0900 | [diff] [blame] | 67 | } // namespace aidl |
Jiyong Park | d911332 | 2020-12-31 03:20:33 +0900 | [diff] [blame] | 68 | } // namespace android |