Clang: Fix highlighting of operators (==, <<, ..)

Handle all enum values that can be reported for clang highlighting
marks.

Change-Id: I07eec789902f36d70fa15f26cad0b151e2adff6e
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Eike Ziller
2017-05-23 15:25:36 +02:00
parent 74a96bd0a6
commit 4b3c0ffc03

View File

@@ -26,6 +26,7 @@
#include "clanghighlightingmarksreporter.h" #include "clanghighlightingmarksreporter.h"
#include <texteditor/textstyles.h> #include <texteditor/textstyles.h>
#include <utils/qtcassert.h>
#include <QFuture> #include <QFuture>
@@ -36,36 +37,45 @@ TextEditor::TextStyle toTextStyle(ClangBackEnd::HighlightingType type)
using ClangBackEnd::HighlightingType; using ClangBackEnd::HighlightingType;
switch (type) { switch (type) {
case HighlightingType::Keyword: case HighlightingType::Keyword:
return TextEditor::C_KEYWORD; return TextEditor::C_KEYWORD;
case HighlightingType::Function: case HighlightingType::Function:
return TextEditor::C_FUNCTION; return TextEditor::C_FUNCTION;
case HighlightingType::VirtualFunction: case HighlightingType::VirtualFunction:
return TextEditor::C_VIRTUAL_METHOD; return TextEditor::C_VIRTUAL_METHOD;
case HighlightingType::Type: case HighlightingType::Type:
return TextEditor::C_TYPE; return TextEditor::C_TYPE;
case HighlightingType::PrimitiveType: case HighlightingType::PrimitiveType:
return TextEditor::C_PRIMITIVE_TYPE; return TextEditor::C_PRIMITIVE_TYPE;
case HighlightingType::LocalVariable: case HighlightingType::LocalVariable:
return TextEditor::C_LOCAL; return TextEditor::C_LOCAL;
case HighlightingType::Field: case HighlightingType::Field:
return TextEditor::C_FIELD; return TextEditor::C_FIELD;
case HighlightingType::GlobalVariable: case HighlightingType::GlobalVariable:
return TextEditor::C_GLOBAL; return TextEditor::C_GLOBAL;
case HighlightingType::Enumeration: case HighlightingType::Enumeration:
return TextEditor::C_ENUMERATION; return TextEditor::C_ENUMERATION;
case HighlightingType::Label: case HighlightingType::Label:
return TextEditor::C_LABEL; return TextEditor::C_LABEL;
case HighlightingType::Preprocessor: case HighlightingType::Preprocessor:
case HighlightingType::PreprocessorDefinition: case HighlightingType::PreprocessorDefinition:
case HighlightingType::PreprocessorExpansion: case HighlightingType::PreprocessorExpansion:
return TextEditor::C_PREPROCESSOR; return TextEditor::C_PREPROCESSOR;
case HighlightingType::Declaration: case HighlightingType::Declaration:
return TextEditor::C_DECLARATION; return TextEditor::C_DECLARATION;
case HighlightingType::OutputArgument: case HighlightingType::OutputArgument:
return TextEditor::C_OUTPUT_ARGUMENT; return TextEditor::C_OUTPUT_ARGUMENT;
default: case HighlightingType::Operator:
return TextEditor::C_TEXT; // never called return TextEditor::C_OPERATOR;
case HighlightingType::Comment:
return TextEditor::C_COMMENT;
case HighlightingType::StringLiteral:
return TextEditor::C_STRING;
case HighlightingType::NumberLiteral:
return TextEditor::C_NUMBER;
case HighlightingType::Invalid:
QTC_CHECK(false); // never called
return TextEditor::C_TEXT;
} }
Q_UNREACHABLE(); Q_UNREACHABLE();