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> 19 #include <stack> 20 #include <string> 21 #include <vector> 22 23 #include <android-base/scopeguard.h> 24 #include <android-base/strings.h> 25 26 class AidlDocument; 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, 41 #include "diagnostics.inc" 42 #undef DIAG 43 }; 44 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 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; 61 62 // relying on Argument-dependent lookup 63 std::string to_string(DiagnosticID id); 64 65 bool Diagnose(const AidlDocument& doc, const DiagnosticMapping& mapping); 66 67 } // namespace aidl 68 } // namespace android 69