| Daniel Norman | cb0d836 | 2019-07-08 11:32:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | |
| 17 | #include "AST.h" |
| 18 | |
| 19 | #include <android-base/logging.h> |
| 20 | #include <hidl-util/Formatter.h> |
| 21 | #include <json/json.h> |
| 22 | #include <string> |
| 23 | #include <vector> |
| 24 | |
| 25 | #include "Interface.h" |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | void AST::generateInheritanceHierarchy(Formatter& out) const { |
| 30 | const Interface* callingIface = mRootScope.getInterface(); |
| 31 | CHECK(callingIface != nullptr); |
| 32 | |
| 33 | Json::Value root; |
| 34 | root["interface"] = callingIface->fqName().string(); |
| 35 | if (callingIface->superType()) { |
| 36 | Json::Value inheritedInterfaces(Json::arrayValue); |
| 37 | for (const Interface* iface : mRootScope.getInterface()->superTypeChain()) { |
| 38 | if (iface->isIBase()) break; |
| 39 | inheritedInterfaces.append(iface->fqName().string()); |
| 40 | } |
| 41 | root["inheritedInterfaces"] = inheritedInterfaces; |
| 42 | } |
| 43 | Json::StyledWriter writer; |
| 44 | out << writer.write(root); |
| 45 | } |
| 46 | |
| 47 | } // namespace android |