forked from qt-creator/qt-creator
C++: Fix highlighting Q_PROPERTY with template types
We override the Q_PROPERTY macro in our own header. This appears to have two effects: 1) The macro arguments are properly highlighted. 2) There is no completion from libclang for Q_PROPERTY, meaning our own helpful snippet is the only completion candidate. I don't understand the reason for either of these; they seem to be more or less random effects of parsing peculiarities. As it turns out, our macro redefinition breaks if the type of the property is based on a template class, leading to false errors in the code model. Removing our macro redefinition fixes the code model, but also removes the aforementioned effects. Turning the macro into a variadic macro fixes the code model and keeps effect 1), but not effect 2). Therefore, we also update the snippet to provide an extra string that makes it clear this it's a helpful snippt, rather than just a normal completion. Fixes: QTCREATORBUG-24243 Change-Id: I4044d5e633af3ebdba36032d5efd3333b5a36214 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -58,8 +58,7 @@
|
||||
# define Q_SLOT __attribute__((annotate("qt_slot")))
|
||||
#endif
|
||||
|
||||
// static_assert can be found as a class child but does not add extra AST nodes for completion
|
||||
#define Q_PROPERTY(arg) static_assert("Q_PROPERTY", #arg);
|
||||
#define Q_PROPERTY(arg...) static_assert("Q_PROPERTY", #arg);
|
||||
|
||||
#define SIGNAL(arg) #arg
|
||||
#define SLOT(arg) #arg
|
||||
|
@@ -204,5 +204,5 @@ case $value$:
|
||||
default:
|
||||
break;
|
||||
}</snippet>
|
||||
<snippet group="C++" trigger="Q_PROPERTY" id="cpp_q_property">Q_PROPERTY($type$ $name$ READ $name$ WRITE set$name:c$ NOTIFY $name$Changed)</snippet>
|
||||
<snippet group="C++" trigger="Q_PROPERTY" id="cpp_q_property" complement="(type name READ name WRITE setName NOTIFY nameChanged)">Q_PROPERTY($type$ $name$ READ $name$ WRITE set$name:c$ NOTIFY $name$Changed)</snippet>
|
||||
</snippets>
|
||||
|
Reference in New Issue
Block a user