diff options
author | Francois Ferrand <thetypz@gmail.com> | 2016-09-12 13:42:42 +0200 |
---|---|---|
committer | Francois Ferrand <thetypz@gmail.com> | 2016-12-05 10:27:58 +0000 |
commit | 38ae5aec1055e4dea2db5f1f9c9ec3b5ae618265 (patch) | |
tree | 9a11846470090fee7ba2a309f00bdd6d2e8f1da0 /src/plugins/cpptools | |
parent | 8f0ddff1ccb402d8fdc68ec0612920547d12876a (diff) | |
download | qt-creator-38ae5aec1055e4dea2db5f1f9c9ec3b5ae618265.tar.gz |
C++: Fix handling of Objective-C/C++
- Objective C/C++ was not enabled in highlighter.
- QMake project part for Objective C/C++ did not have ObjectiveC extension enabled.
- As languageFeatures.objCEnabled is a bitfield, it was actually always set to 0.
- Highlight ObjC class & protocol declarations.
- Highlight ObjC message passing.
Change-Id: I64d12c9509058d05f7adce94598cb7ce91727ac8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r-- | src/plugins/cpptools/cppchecksymbols.cpp | 58 | ||||
-rw-r--r-- | src/plugins/cpptools/cppchecksymbols.h | 7 | ||||
-rw-r--r-- | src/plugins/cpptools/projectpart.cpp | 2 |
3 files changed, 66 insertions, 1 deletions
diff --git a/src/plugins/cpptools/cppchecksymbols.cpp b/src/plugins/cpptools/cppchecksymbols.cpp index 7bc34c903c..83b6bfab9d 100644 --- a/src/plugins/cpptools/cppchecksymbols.cpp +++ b/src/plugins/cpptools/cppchecksymbols.cpp @@ -568,6 +568,58 @@ bool CheckSymbols::visit(ElaboratedTypeSpecifierAST *ast) return false; } +bool CheckSymbols::visit(ObjCProtocolDeclarationAST *ast) +{ + accept(ast->attribute_list); + accept(ast->name); + accept(ast->protocol_refs); + accept(ast->member_declaration_list); + addUse(ast->name, SemanticHighlighter::TypeUse); + return false; +} + +bool CheckSymbols::visit(ObjCProtocolForwardDeclarationAST *ast) +{ + accept(ast->attribute_list); + accept(ast->identifier_list); + for (NameListAST *i = ast->identifier_list; i; i = i->next) + addUse(i->value, SemanticHighlighter::TypeUse); + return false; +} + +bool CheckSymbols::visit(ObjCClassDeclarationAST *ast) +{ + accept(ast->attribute_list); + accept(ast->class_name); + accept(ast->category_name); + accept(ast->superclass); + accept(ast->protocol_refs); + accept(ast->inst_vars_decl); + accept(ast->member_declaration_list); + addUse(ast->class_name, SemanticHighlighter::TypeUse); + if (ast->superclass && maybeType(ast->superclass->name)) + addUse(ast->superclass, SemanticHighlighter::TypeUse); + return false; +} + +bool CheckSymbols::visit(ObjCClassForwardDeclarationAST *ast) +{ + accept(ast->attribute_list); + accept(ast->identifier_list); + for (NameListAST *i = ast->identifier_list ; i != 0; i = i->next) + addUse(i->value, SemanticHighlighter::TypeUse); + return false; +} + +bool CheckSymbols::visit(ObjCProtocolRefsAST *ast) +{ + accept(ast->identifier_list); + for (NameListAST *i = ast->identifier_list; i; i = i->next) + if (maybeType(i->value->name)) + addUse(i->value, SemanticHighlighter::TypeUse); + return false; +} + bool CheckSymbols::visit(MemberAccessAST *ast) { accept(ast->base_expression); @@ -657,6 +709,12 @@ bool CheckSymbols::visit(CallAST *ast) return false; } +bool CheckSymbols::visit(ObjCSelectorArgumentAST *ast) +{ + addUse(ast->firstToken(), SemanticHighlighter::FunctionUse); + return true; +} + bool CheckSymbols::visit(NewExpressionAST *ast) { accept(ast->new_placement); diff --git a/src/plugins/cpptools/cppchecksymbols.h b/src/plugins/cpptools/cppchecksymbols.h index f615341ed0..e4b6a11821 100644 --- a/src/plugins/cpptools/cppchecksymbols.h +++ b/src/plugins/cpptools/cppchecksymbols.h @@ -154,6 +154,12 @@ protected: virtual bool visit(CPlusPlus::ElaboratedTypeSpecifierAST *ast); + virtual bool visit(CPlusPlus::ObjCProtocolDeclarationAST *ast); + virtual bool visit(CPlusPlus::ObjCProtocolForwardDeclarationAST *ast); + virtual bool visit(CPlusPlus::ObjCClassDeclarationAST *ast); + virtual bool visit(CPlusPlus::ObjCClassForwardDeclarationAST *ast); + virtual bool visit(CPlusPlus::ObjCProtocolRefsAST *ast); + virtual bool visit(CPlusPlus::SimpleNameAST *ast); virtual bool visit(CPlusPlus::DestructorNameAST *ast); virtual bool visit(CPlusPlus::QualifiedNameAST *ast); @@ -161,6 +167,7 @@ protected: virtual bool visit(CPlusPlus::MemberAccessAST *ast); virtual bool visit(CPlusPlus::CallAST *ast); + virtual bool visit(CPlusPlus::ObjCSelectorArgumentAST *ast); virtual bool visit(CPlusPlus::NewExpressionAST *ast); virtual bool visit(CPlusPlus::GotoStatementAST *ast); diff --git a/src/plugins/cpptools/projectpart.cpp b/src/plugins/cpptools/projectpart.cpp index 921d981a61..645d3bba5a 100644 --- a/src/plugins/cpptools/projectpart.cpp +++ b/src/plugins/cpptools/projectpart.cpp @@ -48,7 +48,7 @@ void ProjectPart::updateLanguageFeatures() languageFeatures.cxx11Enabled = languageVersion >= CXX11; languageFeatures.cxxEnabled = languageVersion >= CXX98; languageFeatures.c99Enabled = languageVersion >= C99; - languageFeatures.objCEnabled = languageExtensions & ObjectiveCExtensions; + languageFeatures.objCEnabled = languageExtensions.testFlag(ObjectiveCExtensions); languageFeatures.qtEnabled = hasQt; languageFeatures.qtMocRunEnabled = hasQt; if (!hasQt) { |