| 1 | /**************************************************************************** |
| 2 | * Copyright (C) 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> |
| 3 | * |
| 4 | * This file is part of the Code Browser. |
| 5 | * |
| 6 | * Commercial License Usage: |
| 7 | * Licensees holding valid commercial licenses provided by KDAB may use |
| 8 | * this file in accordance with the terms contained in a written agreement |
| 9 | * between the licensee and KDAB. |
| 10 | * For further information see https://codebrowser.dev/ |
| 11 | * |
| 12 | * Alternatively, this work may be used under a Creative Commons |
| 13 | * Attribution-NonCommercial-ShareAlike 3.0 (CC-BY-NC-SA 3.0) License. |
| 14 | * http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US |
| 15 | * This license does not allow you to use the code browser to assist the |
| 16 | * development of your commercial software. If you intent to do so, consider |
| 17 | * purchasing a commercial licence. |
| 18 | ****************************************************************************/ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include <clang/AST/Expr.h> |
| 23 | #include <clang/Basic/SourceManager.h> |
| 24 | |
| 25 | class Annotator; |
| 26 | |
| 27 | class InlayHintsAnnotatorHelper |
| 28 | { |
| 29 | public: |
| 30 | InlayHintsAnnotatorHelper(Annotator *annotator); |
| 31 | |
| 32 | llvm::DenseMap<clang::SourceLocation, std::string> |
| 33 | getDesignatorInlayHints(clang::InitListExpr *Syn); |
| 34 | |
| 35 | std::string getParamNameInlayHint(clang::CallExpr *callExpr, clang::ParmVarDecl *paramDecl, |
| 36 | clang::Expr *arg); |
| 37 | |
| 38 | private: |
| 39 | // Checks if "E" is spelled in the main file and preceded by a C-style comment |
| 40 | // whose contents match ParamName (allowing for whitespace and an optional "=" |
| 41 | // at the end. |
| 42 | bool (const clang::Expr *E, llvm::StringRef ParamName, |
| 43 | llvm::StringRef mainFileBuf); |
| 44 | |
| 45 | clang::SourceManager &SM; |
| 46 | clang::FileID mainFileID; |
| 47 | }; |
| 48 | |