diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-01-16 10:51:13 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-05-16 14:06:04 +0000 |
commit | 837cb2e3974b4b8d157be8234adcd11b226a7caf (patch) | |
tree | fbcd833998a7572b2775d0e2e185d5bddb2177ce /src/plugins/cppeditor/cpphighlighter.cpp | |
parent | 5bc796094accf4f63d6a821b55daeb718506cb1a (diff) |
CppEditor: Do not highlight C++ and Qt keywords for C
Task-number: QTCREATORBUG-2818
Task-number: QTCREATORBUG-18004
Change-Id: Ibca60a1711c827dd8b4c0486bff3d49b19a61d8b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/cppeditor/cpphighlighter.cpp')
-rw-r--r-- | src/plugins/cppeditor/cpphighlighter.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index 1912f30ff1..f5d7f104f4 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -70,15 +70,8 @@ void CppHighlighter::highlightBlock(const QString &text) int braceDepth = initialBraceDepth; - // FIXME: Check defaults or get from document. - LanguageFeatures features; - features.cxx11Enabled = true; - features.cxxEnabled = true; - features.c99Enabled = true; - features.objCEnabled = true; - SimpleLexer tokenize; - tokenize.setLanguageFeatures(features); + tokenize.setLanguageFeatures(m_languageFeatures); int initialLexerState = lexerState; const Tokens tokens = tokenize(text, initialLexerState); @@ -215,7 +208,8 @@ void CppHighlighter::highlightBlock(const QString &text) } } else if (tk.isKeyword() - || CppTools::isQtKeyword(text.midRef(tk.utf16charsBegin(), tk.utf16chars())) + || (m_languageFeatures.qtKeywordsEnabled + && CppTools::isQtKeyword(text.midRef(tk.utf16charsBegin(), tk.utf16chars()))) || tk.isObjCAtKeyword()) { setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(CppKeywordFormat)); } else if (tk.isPrimitiveType()) { @@ -281,6 +275,13 @@ void CppHighlighter::highlightBlock(const QString &text) setCurrentBlockState((braceDepth << 8) | tokenize.state()); } +void CppHighlighter::setLanguageFeatures(const LanguageFeatures &languageFeatures) +{ + if (languageFeatures != m_languageFeatures) { + m_languageFeatures = languageFeatures; + rehighlight(); + } +} bool CppHighlighter::isPPKeyword(const QStringRef &text) const { |