75class MainWindow :
public QMainWindow {
79 explicit MainWindow(QWidget *parent =
nullptr);
80 ~MainWindow()
override;
87 const QString &projectRoot = QString());
91 void onOpenCompilationDatabase();
95 void onTranslationUnitSelected(
const QModelIndex &index);
96 void onTranslationUnitClicked(
const QModelIndex &index);
99 void onDependenciesReady(
const QJsonObject &dependencies);
100 void onDependenciesReadyWithErrors(
const QJsonObject &dependencies,
101 const QStringList &errorMessages);
102 void onDependenciesError(
const QString &errorMessage);
103 void onDependenciesProgress(
const QString &message);
106 void onAstReady(
const QString &astFilePath);
108 void onAstError(
const QString &errorMessage);
109 void onMakeAstLogMessage(
const LogEntry &entry);
110 void onAstProgress(
const QString &message);
112 void onTimingMessage(
const QString &message);
113 void onAstContextMenuRequested(
const QPoint &pos);
116 void onExpandAllAstChildren();
117 void onCollapseAllAstChildren();
118 void onGoToMacroDefinition();
121 void onTuContextMenuRequested(
const QPoint &pos);
122 void onExpandAllTuChildren();
123 void onCollapseAllTuChildren();
126 void onAstNodeSelected(
const QModelIndex &index);
127 void onSourcePositionClicked(
FileID fileId,
unsigned line,
unsigned column);
128 void onSourceRangeSelected(
FileID fileId,
unsigned startLine,
129 unsigned startColumn,
unsigned endLine,
132 void onCycleWidgetClosed();
133 void onSourceSearchTextChanged(
const QString &text);
134 void onSourceSearchDebounced();
135 void onSourceSearchFindNext();
136 void onSourceSearchFindPrevious();
137 void onAstSearchTextChanged(
const QString &text);
138 void onAstSearchDebounced();
139 void onAstSearchFindNext();
140 void onAstSearchFindPrevious();
142 void onResetLayout();
143 void onFocusChanged(QWidget *old, QWidget *now);
146 void resizeEvent(QResizeEvent *event)
override;
147 void moveEvent(QMoveEvent *event)
override;
148 bool eventFilter(QObject *watched, QEvent *event)
override;
151 friend class MainWindowTestAccess;
156 void setupDockWidgets();
158 void setupTuSearch();
159 void setupSourceSearchPanel(QWidget *container);
160 void setupAstSearchPanel(QWidget *container);
161 void setupSettingsAction();
162 void applyUnifiedSelectionPalette();
163 void setupViewMenuDockActions();
164 void applyFontSize(
int size);
165 void adjustFontSize(
int delta);
166 void expandFileExplorerTopLevel();
167 void connectSignals();
170 void logStatus(LogLevel level,
const QString &message,
171 const QString &source = QString());
174 void extractAst(
const QString &astFilePath,
const QString &sourceFilePath);
175 QStringList getFileListForSource(
const QString &sourceFilePath)
const;
176 bool isSourceFile(
const QString &filePath)
const;
177 bool deleteCachedAst(
const QString &astFilePath);
178 QString astCacheStatusFilePath(
const QString &astFilePath)
const;
179 void persistAstCompilationErrorState(
const QString &astFilePath,
180 bool hasCompilationErrors);
181 bool loadAstCompilationErrorState(
const QString &astFilePath)
const;
189 std::size_t astVersion;
192 void recordHistory(
FileID fileId,
unsigned line,
unsigned column,
195 void navigateHistory(
int delta);
196 void applyEntry(
const NavEntry &entry);
197 void updateNavActions();
198 void onOpenConfigFile();
199 void onReloadConfig();
200 QString buildDefaultExportFileName(
AstViewNode *node)
const;
201 void triggerSourceSearch(
bool forward);
202 void triggerAstSearch(
bool forward);
203 void collectAstSearchMatches(
const QString &expression);
204 void navigateToAstMatch(
int index);
205 void clearAstSearchState();
206 void setAstSearchStatus(
const QString &text,
bool isError);
207 void showAstSearchPopup(
bool selectAll =
false);
208 void syncAstSearchPopupGeometry();
209 void rememberAstSearchQuery(
const QString &query);
210 void setAstCompilationWarningVisible(
bool visible);
211 void expandAllChildren(QTreeView *view);
212 void expandSubtree(QTreeView *view);
213 void collapseAllChildren(QTreeView *view);
214 void collapseTuDirectories(QTreeView *view);
215 void collapseRecursively(
const QModelIndex &index, QTreeView *view);
216 void highlightTuFile(
FileID fileId);
218 bool skipCursorMove);
219 bool getMacroSpellingRange(
const AstViewNode *node,
224 bool validateSourceLookup(
FileID fileId);
227 void logNoNodeFound(
FileID fileId,
const QString &fallbackMessage);
230 void updateSourceSubtitle(
const QString &filePath);
233 void updateAstSubtitle(
const QString &mainSourcePath);
238 QAction *openAction_;
239 QAction *exitAction_;
240 QAction *settingsAction_;
241 QAction *reloadConfigAction_;
242 QAction *navBackAction_;
243 QAction *navForwardAction_;
244 QAction *goToMacroDefinitionAction_;
245 QAction *zoomInAction_;
246 QAction *zoomOutAction_;
247 QAction *zoomResetAction_;
248 QToolBar *navToolBar_;
249 QAction *resetLayoutAction_;
250 QLineEdit *tuSearch_;
251 QLineEdit *sourceSearchInput_;
252 QToolButton *sourceSearchPrevButton_;
253 QToolButton *sourceSearchNextButton_;
254 QLabel *sourceSearchStatus_;
255 ::QTimer *sourceSearchDebounce_;
258 QDialog *astSearchPopup_ =
nullptr;
259 QLineEdit *astSearchQuickInput_ =
nullptr;
260 QLineEdit *astSearchInput_ =
nullptr;
261 QToolButton *astSearchPrevButton_ =
nullptr;
262 QToolButton *astSearchNextButton_ =
nullptr;
263 QLabel *astSearchStatus_ =
nullptr;
264 QLabel *astCompilationWarningLabel_ =
nullptr;
265 QCheckBox *astSearchProjectFilter_ =
nullptr;
266 QCompleter *astSearchCompleter_ =
nullptr;
267 QStringListModel *astSearchHistoryModel_ =
nullptr;
268 QStringList astSearchHistory_;
269 std::vector<AstViewNode *> astSearchMatches_;
270 int astSearchCurrentIndex_ = -1;
273 QDockWidget *tuDock_;
274 QDockWidget *sourceDock_;
275 QDockWidget *astDock_;
276 QDockWidget *declContextDock_;
294 QThread *astWorkerThread_;
295 QThread *astExportThread_ =
nullptr;
297 std::unique_ptr<AstContext> astContext_;
300 static constexpr int kParallelThreshold = 10;
301 static constexpr int kMinFontSize = 8;
302 static constexpr int kMaxFontSize = 32;
305 QString compilationDatabasePath_;
306 QString projectRoot_;
307 QString currentSourceFilePath_;
308 QString lastAstFilePath_;
309 bool isAstExtractionInProgress_;
310 bool isAstExportInProgress_ =
false;
311 QString pendingSourceFilePath_;
312 bool astHasCompilationErrors_ =
false;
313 std::size_t astVersion_ = 0;
314 int currentFontSize_ = 11;
315 QString currentFontFamily_;
318 int tuFontSize_ = 11;
319 int sourceFontSize_ = 11;
320 int astFontSize_ = 11;
321 int declContextFontSize_ = 11;
322 int logFontSize_ = 11;
324 QByteArray defaultDockState_;
328 std::vector<NavEntry> history_;
329 std::size_t historyCursor_ = 0;
330 bool suppressHistory_ =
false;
331 bool suppressSourceCursorMove_ =
false;
332 bool suppressSourceHighlight_ =
false;
333 bool isNavigatingFromDeclContext_ =
false;
336 QDockWidget *focusedDock_ =
nullptr;
Declaration context hierarchy display panel.
Memory manager for AST nodes in a translation unit.
Panel displaying declaration context hierarchy for selected AST node.
void loadCompilationDatabase(const QString &compilationDatabasePath, const QString &projectRoot=QString())
Load compilation database and populate translation units.