From 3aed85991fc96a4db40931b0eb1e79986b0bffa9 Mon Sep 17 00:00:00 2001 From: James Surgenor Date: Mon, 3 May 2021 17:07:43 +0100 Subject: [PATCH 1/3] [scide] Mark SyntaxHighlighter::highlightBlock as override --- editors/sc-ide/widgets/code_editor/highlighter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/sc-ide/widgets/code_editor/highlighter.hpp b/editors/sc-ide/widgets/code_editor/highlighter.hpp index 33e5fdab3a8..0fae956c6f0 100644 --- a/editors/sc-ide/widgets/code_editor/highlighter.hpp +++ b/editors/sc-ide/widgets/code_editor/highlighter.hpp @@ -89,7 +89,7 @@ class SyntaxHighlighter : public QSyntaxHighlighter { SyntaxHighlighter(QTextDocument* parent = 0); private: - void highlightBlock(const QString& text); + void highlightBlock(const QString& text) override; void highlightBlockInCode(ScLexer& lexer); void highlightBlockInString(ScLexer& lexer); void highlightBlockInSymbol(ScLexer& lexer); From c28dff4da827f587f533ffb006ac0e638cae8159 Mon Sep 17 00:00:00 2001 From: James Surgenor Date: Mon, 3 May 2021 17:10:45 +0100 Subject: [PATCH 2/3] [scide] Check introspection is available before highlighting --- editors/sc-ide/widgets/code_editor/highlighter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/editors/sc-ide/widgets/code_editor/highlighter.cpp b/editors/sc-ide/widgets/code_editor/highlighter.cpp index e9a330ce817..6588cfdfde2 100644 --- a/editors/sc-ide/widgets/code_editor/highlighter.cpp +++ b/editors/sc-ide/widgets/code_editor/highlighter.cpp @@ -208,6 +208,10 @@ void SyntaxHighlighter::highlightBlockInComment(ScLexer& lexer) { } void SyntaxHighlighter::highlightBlock(const QString& text) { + // if we don't have introspection yet don't format anything + if (!Main::scProcess()->introspection().introspectionAvailable()) + return; + TextBlockData* blockData = static_cast(currentBlockUserData()); if (!blockData) { blockData = new TextBlockData; From ff0913447736ab5f980cada5d9dac9d74cfceebd Mon Sep 17 00:00:00 2001 From: James Surgenor Date: Mon, 3 May 2021 17:11:28 +0100 Subject: [PATCH 3/3] [scide] rehighlight when introspection changes --- editors/sc-ide/widgets/code_editor/highlighter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/editors/sc-ide/widgets/code_editor/highlighter.cpp b/editors/sc-ide/widgets/code_editor/highlighter.cpp index 6588cfdfde2..997d00fc3b2 100644 --- a/editors/sc-ide/widgets/code_editor/highlighter.cpp +++ b/editors/sc-ide/widgets/code_editor/highlighter.cpp @@ -68,6 +68,8 @@ SyntaxHighlighter::SyntaxHighlighter(QTextDocument* parent): QSyntaxHighlighter( mGlobals = SyntaxHighlighterGlobals::instance(); connect(mGlobals, SIGNAL(syntaxFormatsChanged()), this, SLOT(rehighlight())); + + connect(Main::scProcess(), &ScProcess::introspectionChanged, this, &SyntaxHighlighter::rehighlight); } void SyntaxHighlighter::highlightBlockInCode(ScLexer& lexer) { @@ -88,6 +90,7 @@ void SyntaxHighlighter::highlightBlockInCode(ScLexer& lexer) { case Token::Class: { auto className = QString(lexer.text().begin() + tokenPosition, tokenLength); + auto* classInstance = Main::scProcess()->introspection().findClass(className); if (classInstance != nullptr)