diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-06-25 17:18:30 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-07-08 14:41:11 +0000 |
commit | 53b4d6975d5458395c10b55e99d12886ea224c49 (patch) | |
tree | f0c27d92e0ddf981b75dd71bdaa04672104ea0d8 | |
parent | 59aa4f80330cf39cc26c6b2d2f1578096511ef9e (diff) |
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>
-rw-r--r-- | share/qtcreator/cplusplus/wrappedQtHeaders/QtCore/qobjectdefs.h | 3 | ||||
-rw-r--r-- | share/qtcreator/snippets/cpp.xml | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore/qobjectdefs.h b/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore/qobjectdefs.h index c215327c680..15d19ea7b49 100644 --- a/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore/qobjectdefs.h +++ b/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore/qobjectdefs.h @@ -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 diff --git a/share/qtcreator/snippets/cpp.xml b/share/qtcreator/snippets/cpp.xml index 5ade1dc1c8b..17cf2ebf1ca 100644 --- a/share/qtcreator/snippets/cpp.xml +++ b/share/qtcreator/snippets/cpp.xml @@ -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> |