Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[scide] Fix classname highlighting before introspection available #5438

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions editors/sc-ide/widgets/code_editor/highlighter.cpp
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down Expand Up @@ -208,6 +211,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<TextBlockData*>(currentBlockUserData());
if (!blockData) {
blockData = new TextBlockData;
Expand Down
2 changes: 1 addition & 1 deletion editors/sc-ide/widgets/code_editor/highlighter.hpp
Expand Up @@ -89,7 +89,7 @@ class SyntaxHighlighter : public QSyntaxHighlighter {
SyntaxHighlighter(QTextDocument* parent = 0);

private:
void highlightBlock(const QString& text);
void highlightBlock(const QString& text) override;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious - why is the override keyword needed now and not before? Or - was part of the problem that this wasn't marked as override properly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it wasn't there before, this is very much a "leave the code better than you found it" commit

void highlightBlockInCode(ScLexer& lexer);
void highlightBlockInString(ScLexer& lexer);
void highlightBlockInSymbol(ScLexer& lexer);
Expand Down