diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2016-12-08 10:14:11 -0500 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2016-12-08 12:12:50 -0500 |
commit | dad775b79895df5167cfbc2c78549b8417af1c01 (patch) | |
tree | 6a880f4c75e6ed88ebfa18c8122c81fe4ec757be /src/google/protobuf/compiler/objectivec/objectivec_helpers.h | |
parent | c836ad4dc7db4adf4b42a30474037f712d4f6875 (diff) |
Improve ObjC deprecated annotation support.
- Check the parent file options for deprecation when deciding to tag Messages
and Enums as deprecated.
- Within the generated source push/pop the warning for implementing deprecated
things around a deprecated class implementation.
- Annotate the methods generated for extension fields as deprecated.
- Add a testing .proto file that covers deprecated fields, messages, enums,
enum values and compile it into the unittests to confirm things compile
cleanly.
- Add a testing .proto file that uses the file level option to make everything
deprecated and compile it into the unittests to confirm things compile
cleanly.
Diffstat (limited to 'src/google/protobuf/compiler/objectivec/objectivec_helpers.h')
-rw-r--r-- | src/google/protobuf/compiler/objectivec/objectivec_helpers.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h index 316069e1..a2179446 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h @@ -150,8 +150,18 @@ enum FlagType { }; template<class TDescriptor> -string GetOptionalDeprecatedAttribute(const TDescriptor* descriptor, bool preSpace = true, bool postNewline = false) { - if (descriptor->options().deprecated()) { +string GetOptionalDeprecatedAttribute( + const TDescriptor* descriptor, + const FileDescriptor* file = NULL, + bool preSpace = true, bool postNewline = false) { + bool isDeprecated = descriptor->options().deprecated(); + // The file is only passed when checking Messages & Enums, so those types + // get tagged. At the moment, it doesn't seem to make sense to tag every + // field or enum value with when the file is deprecated. + if (!isDeprecated && file) { + isDeprecated = file->options().deprecated(); + } + if (isDeprecated) { string result = "DEPRECATED_ATTRIBUTE"; if (preSpace) { result.insert(0, " "); |