diff options
author | Erik Verbruggen <[email protected]> | 2012-02-07 15:59:08 +0100 |
---|---|---|
committer | Erik Verbruggen <[email protected]> | 2012-02-09 13:32:46 +0100 |
commit | db25f9a13671015b33f57e8c2338c10ddc7c7202 (patch) | |
tree | c9d0707c3ac29185e3d3be7aef4ee8aaadeac4f2 /src/plugins | |
parent | eb521323ca41766c6ea3c785db4fb7eeaf2b4df1 (diff) |
C++: Added highlighting for labels.
Change-Id: I559a3112d2aa0a3c09554f8da8b7917f9aa27944
Reviewed-by: Roberto Raggi <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/cppeditor/cppeditor.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cpptools/cppchecksymbols.cpp | 17 | ||||
-rw-r--r-- | src/plugins/cpptools/cppchecksymbols.h | 3 | ||||
-rw-r--r-- | src/plugins/cpptools/cppsemanticinfo.h | 6 |
4 files changed, 26 insertions, 2 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 9870716f0ba..235360fe0ce 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -1717,6 +1717,8 @@ void CPPEditorWidget::setFontSettings(const TextEditor::FontSettings &fs) fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_STATIC)); m_semanticHighlightFormatMap[SemanticInfo::VirtualMethodUse] = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_VIRTUAL_METHOD)); + m_semanticHighlightFormatMap[SemanticInfo::LabelUse] = + fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_LABEL)); m_keywordFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_KEYWORD)); // only set the background, we do not want to modify foreground properties set by the syntax highlighter or the link diff --git a/src/plugins/cpptools/cppchecksymbols.cpp b/src/plugins/cpptools/cppchecksymbols.cpp index 84e99548a1f..82e72452c84 100644 --- a/src/plugins/cpptools/cppchecksymbols.cpp +++ b/src/plugins/cpptools/cppchecksymbols.cpp @@ -765,6 +765,23 @@ bool CheckSymbols::visit(MemInitializerAST *ast) return false; } +bool CheckSymbols::visit(GotoStatementAST *ast) +{ + if (ast->identifier_token) + addUse(ast->identifier_token, SemanticInfo::LabelUse); + + return false; +} + +bool CheckSymbols::visit(LabeledStatementAST *ast) +{ + if (ast->label_token) + addUse(ast->label_token, SemanticInfo::LabelUse); + + accept(ast->statement); + return false; +} + bool CheckSymbols::visit(FunctionDefinitionAST *ast) { AST *thisFunction = _astStack.takeLast(); diff --git a/src/plugins/cpptools/cppchecksymbols.h b/src/plugins/cpptools/cppchecksymbols.h index fb50fcfd52a..d3b638ec70d 100644 --- a/src/plugins/cpptools/cppchecksymbols.h +++ b/src/plugins/cpptools/cppchecksymbols.h @@ -154,6 +154,9 @@ protected: virtual bool visit(MemInitializerAST *ast); + virtual bool visit(GotoStatementAST *ast); + virtual bool visit(LabeledStatementAST *ast); + NameAST *declaratorId(DeclaratorAST *ast) const; void flush(); diff --git a/src/plugins/cpptools/cppsemanticinfo.h b/src/plugins/cpptools/cppsemanticinfo.h index 915ffad1f55..af57130071d 100644 --- a/src/plugins/cpptools/cppsemanticinfo.h +++ b/src/plugins/cpptools/cppsemanticinfo.h @@ -46,11 +46,13 @@ class CPPTOOLS_EXPORT SemanticInfo { public: enum UseKind { - TypeUse = 0, + Unknown = 0, + TypeUse, LocalUse, FieldUse, StaticUse, - VirtualMethodUse + VirtualMethodUse, + LabelUse }; typedef TextEditor::SemanticHighlighter::Result Use; |