forked from qt-creator/qt-creator
SyntaxHighlighter: Move generic highlighter to separate thread
Adds a full copy of KSyntaxHighlighting::Repository class to the Highlighter class, enabling the relocation of the Highlighter class to a separate thread. This adjustment ensures that all Definitions come from the copy of the repository, making them immutable from external code. The "reload Definition" function stays supported, as triggering it results in the recreation of the highlighter for the document, thereby reconstructing the Repository class. Change-Id: Id7a4d865228c7e7e20e4770601a3fde55b8a6513 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -68,15 +68,24 @@ TextStyle categoryForTextStyle(int style)
|
||||
return C_TEXT;
|
||||
}
|
||||
|
||||
Highlighter::Highlighter()
|
||||
Highlighter::Highlighter(const QString &definitionFilesPath)
|
||||
: m_repository(new KSyntaxHighlighting::Repository())
|
||||
{
|
||||
m_repository->addCustomSearchPath(definitionFilesPath);
|
||||
const Utils::FilePath dir = Core::ICore::resourcePath("generic-highlighter/syntax");
|
||||
if (dir.exists())
|
||||
m_repository->addCustomSearchPath(dir.parentDir().path());
|
||||
m_repository->reload();
|
||||
|
||||
setTextFormatCategories(QMetaEnum::fromType<KSyntaxHighlighting::Theme::TextStyle>().keyCount(),
|
||||
&categoryForTextStyle);
|
||||
}
|
||||
|
||||
KSyntaxHighlighting::Definition Highlighter::getDefinition()
|
||||
Highlighter::~Highlighter() = default;
|
||||
|
||||
void Highlighter::setDefinitionName(const QString &name)
|
||||
{
|
||||
return definition();
|
||||
KSyntaxHighlighting::AbstractHighlighter::setDefinition(m_repository->definitionForName(name));
|
||||
}
|
||||
|
||||
static bool isOpeningParenthesis(QChar c)
|
||||
|
||||
Reference in New Issue
Block a user