forked from qt-creator/qt-creator
C++: Added highlighting for labels.
Change-Id: I559a3112d2aa0a3c09554f8da8b7917f9aa27944 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
@@ -1717,6 +1717,8 @@ void CPPEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
|
|||||||
fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_STATIC));
|
fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_STATIC));
|
||||||
m_semanticHighlightFormatMap[SemanticInfo::VirtualMethodUse] =
|
m_semanticHighlightFormatMap[SemanticInfo::VirtualMethodUse] =
|
||||||
fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_VIRTUAL_METHOD));
|
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));
|
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
|
// only set the background, we do not want to modify foreground properties set by the syntax highlighter or the link
|
||||||
|
|||||||
@@ -765,6 +765,23 @@ bool CheckSymbols::visit(MemInitializerAST *ast)
|
|||||||
return false;
|
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)
|
bool CheckSymbols::visit(FunctionDefinitionAST *ast)
|
||||||
{
|
{
|
||||||
AST *thisFunction = _astStack.takeLast();
|
AST *thisFunction = _astStack.takeLast();
|
||||||
|
|||||||
@@ -154,6 +154,9 @@ protected:
|
|||||||
|
|
||||||
virtual bool visit(MemInitializerAST *ast);
|
virtual bool visit(MemInitializerAST *ast);
|
||||||
|
|
||||||
|
virtual bool visit(GotoStatementAST *ast);
|
||||||
|
virtual bool visit(LabeledStatementAST *ast);
|
||||||
|
|
||||||
NameAST *declaratorId(DeclaratorAST *ast) const;
|
NameAST *declaratorId(DeclaratorAST *ast) const;
|
||||||
|
|
||||||
void flush();
|
void flush();
|
||||||
|
|||||||
@@ -46,11 +46,13 @@ class CPPTOOLS_EXPORT SemanticInfo
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum UseKind {
|
enum UseKind {
|
||||||
TypeUse = 0,
|
Unknown = 0,
|
||||||
|
TypeUse,
|
||||||
LocalUse,
|
LocalUse,
|
||||||
FieldUse,
|
FieldUse,
|
||||||
StaticUse,
|
StaticUse,
|
||||||
VirtualMethodUse
|
VirtualMethodUse,
|
||||||
|
LabelUse
|
||||||
};
|
};
|
||||||
typedef TextEditor::SemanticHighlighter::Result Use;
|
typedef TextEditor::SemanticHighlighter::Result Use;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user