forked from qt-creator/qt-creator
CppTools: Fix parentheses mismatch
... when the ClangCodeModel is disabled.
The built-in highlighter's use of HighlightingResult::kind conflicted
with the ClangCodeModel's.
Amends d8c1e51bfe.
Change-Id: I79784679fd17d88cd543304de726f8576954b29c
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "clanghighlightingresultreporter.h"
|
||||
|
||||
#include <cpptools/semantichighlighter.h>
|
||||
#include <texteditor/textstyles.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -143,9 +144,9 @@ TextEditor::HighlightingResult toHighlightingResult(
|
||||
TextEditor::HighlightingResult result(tokenInfo.line, tokenInfo.column, tokenInfo.length,
|
||||
textStyles);
|
||||
if (tokenInfo.types.mixinHighlightingTypes.contains(HighlightingType::AngleBracketOpen))
|
||||
result.kind = 1;
|
||||
result.kind = CppTools::SemanticHighlighter::AngleBracketOpen;
|
||||
else if (tokenInfo.types.mixinHighlightingTypes.contains(HighlightingType::AngleBracketClose))
|
||||
result.kind = 2;
|
||||
result.kind = CppTools::SemanticHighlighter::AngleBracketClose;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ void SemanticHighlighter::onHighlighterResultAvailable(int from, int to)
|
||||
QPair<QTextBlock, Parentheses> parentheses;
|
||||
for (int i = from; i < to; ++i) {
|
||||
const HighlightingResult &result = m_watcher->future().resultAt(i);
|
||||
if (result.kind == 0)
|
||||
if (result.kind != AngleBracketOpen && result.kind != AngleBracketClose)
|
||||
continue;
|
||||
if (parentheses.first.isValid() && result.line - 1 > parentheses.first.blockNumber()) {
|
||||
TextDocumentLayout::setParentheses(parentheses.first, parentheses.second);
|
||||
@@ -175,7 +175,7 @@ void SemanticHighlighter::onHighlighterResultAvailable(int from, int to)
|
||||
parentheses.first = m_baseTextDocument->document()->findBlockByNumber(result.line - 1);
|
||||
parentheses.second = TextDocumentLayout::parentheses(parentheses.first);
|
||||
}
|
||||
if (result.kind == 1)
|
||||
if (result.kind == AngleBracketOpen)
|
||||
parentheses.second << Parenthesis(Parenthesis::Opened, '<', result.column - 1);
|
||||
else
|
||||
parentheses.second << Parenthesis(Parenthesis::Closed, '>', result.column - 1);
|
||||
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
StringUse,
|
||||
FunctionDeclarationUse,
|
||||
VirtualFunctionDeclarationUse,
|
||||
AngleBracketOpen,
|
||||
AngleBracketClose,
|
||||
};
|
||||
|
||||
using HighlightingRunner = std::function<QFuture<TextEditor::HighlightingResult> ()>;
|
||||
|
||||
Reference in New Issue
Block a user