IDE开发系列(2)扩展的IDE框架设计
扩展之前的IDE框架,包含语法高亮、代码补全、项目管理等所有建议功能。
1. 语法高亮实现
// SyntaxHighlighter.h
#pragma once#include <QSyntaxHighlighter>
#include <QTextCharFormat>
#include <QRegularExpression>class SyntaxHighlighter : public QSyntaxHighlighter
{Q_OBJECTpublic:SyntaxHighlighter(QTextDocument *parent = nullptr);protected:void highlightBlock(const QString &text) override;private:struct HighlightingRule{QRegularExpression pattern;QTextCharFormat format;};QVector<HighlightingRule> highlightingRules;QRegularExpression commentStartExpression;QRegularExpression commentEndExpression;QTextCharFormat keywordFormat;QTextCharFormat classFormat;QTextCharFormat si