ACAV f0ba4b7c9529
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
Loading...
Searching...
No Matches
DeclContextView.h
Go to the documentation of this file.
1/*$!{
2* Aurora Clang AST Viewer (ACAV)
3*
4* Copyright (c) 2026 Min Liu
5* Copyright (c) 2026 Michael David Adams
6*
7* SPDX-License-Identifier: GPL-2.0-or-later
8*
9* This program is free software; you can redistribute it and/or modify
10* it under the terms of the GNU General Public License as published by
11* the Free Software Foundation; either version 2 of the License, or
12* (at your option) any later version.
13*
14* This program is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17* GNU General Public License for more details.
18*
19* You should have received a copy of the GNU General Public License along
20* with this program; if not, see <https://www.gnu.org/licenses/>.
21}$!*/
22
25#pragma once
26
27#include "core/AstNode.h"
28#include <QString>
29#include <QTreeWidget>
30#include <QWidget>
31
32class QLabel;
33class QVBoxLayout;
34
35namespace acav {
36
43class DeclContextView : public QWidget {
44 Q_OBJECT
45
46public:
47 explicit DeclContextView(QWidget *parent = nullptr);
48 ~DeclContextView() override = default;
49
50signals:
53
54public slots:
57 void setSelectedNode(AstViewNode *node);
58
60 void clear();
61
63 void focusSemanticTree();
64
66 void focusLexicalTree();
67
69 void applyFont(const QFont &font);
70
71private slots:
73 void onContextItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
74
75private:
77 void setupUI();
78
81 void populateContextHierarchy(AstViewNode *node);
82
84 void showNotApplicable();
85
87 void populateContextTree(QTreeWidget *tree, const AcavJson *contextArray,
88 bool highlightLast);
89
91 void applyKindStyling(QTreeWidgetItem *item, const QString &kind) const;
92
93 // UI components
94 QLabel *semanticLabel_;
95 QLabel *lexicalLabel_;
96 QTreeWidget *semanticTree_;
97 QTreeWidget *lexicalTree_;
98};
99
100} // namespace acav
AST data structures and memory management.
nlohmann::basic_json< std::map, std::vector, InternedString, bool, int64_t, uint64_t, double, std::allocator, nlohmann::adl_serializer, std::vector< uint8_t > > AcavJson
Custom JSON type using InternedString for automatic string deduplication.
Definition AstNode.h:51
Represents node in AST tree hierarchy.
Definition AstNode.h:195
void clear()
Clear the display.
void applyFont(const QFont &font)
Propagate font to all internal widgets (labels + trees).
void contextNodeClicked(AstViewNode *node)
Emitted when user clicks a context entry to navigate to that node.
void focusLexicalTree()
Set focus to lexical context tree.
void setSelectedNode(AstViewNode *node)
Update display for selected node.
void focusSemanticTree()
Set focus to semantic context tree.