diff options
Diffstat (limited to 'tools/aapt2/java/AnnotationProcessor.cpp')
-rw-r--r-- | tools/aapt2/java/AnnotationProcessor.cpp | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/tools/aapt2/java/AnnotationProcessor.cpp b/tools/aapt2/java/AnnotationProcessor.cpp index 23ff8abf8950..2951e5cff6d7 100644 --- a/tools/aapt2/java/AnnotationProcessor.cpp +++ b/tools/aapt2/java/AnnotationProcessor.cpp @@ -15,69 +15,71 @@ */ #include "java/AnnotationProcessor.h" -#include "util/Util.h" #include <algorithm> +#include "util/Util.h" + namespace aapt { -void AnnotationProcessor::appendCommentLine(std::string& comment) { - static const std::string sDeprecated = "@deprecated"; - static const std::string sSystemApi = "@SystemApi"; +void AnnotationProcessor::AppendCommentLine(std::string& comment) { + static const std::string sDeprecated = "@deprecated"; + static const std::string sSystemApi = "@SystemApi"; - if (comment.find(sDeprecated) != std::string::npos) { - mAnnotationBitMask |= kDeprecated; - } + if (comment.find(sDeprecated) != std::string::npos) { + annotation_bit_mask_ |= kDeprecated; + } - std::string::size_type idx = comment.find(sSystemApi); - if (idx != std::string::npos) { - mAnnotationBitMask |= kSystemApi; - comment.erase(comment.begin() + idx, comment.begin() + idx + sSystemApi.size()); - } + std::string::size_type idx = comment.find(sSystemApi); + if (idx != std::string::npos) { + annotation_bit_mask_ |= kSystemApi; + comment.erase(comment.begin() + idx, + comment.begin() + idx + sSystemApi.size()); + } - if (util::trimWhitespace(comment).empty()) { - return; - } + if (util::TrimWhitespace(comment).empty()) { + return; + } - if (!mHasComments) { - mHasComments = true; - mComment << "/**"; - } + if (!has_comments_) { + has_comments_ = true; + comment_ << "/**"; + } - mComment << "\n * " << std::move(comment); + comment_ << "\n * " << std::move(comment); } -void AnnotationProcessor::appendComment(const StringPiece& comment) { - // We need to process line by line to clean-up whitespace and append prefixes. - for (StringPiece line : util::tokenize(comment, '\n')) { - line = util::trimWhitespace(line); - if (!line.empty()) { - std::string lineCopy = line.toString(); - appendCommentLine(lineCopy); - } +void AnnotationProcessor::AppendComment(const StringPiece& comment) { + // We need to process line by line to clean-up whitespace and append prefixes. + for (StringPiece line : util::Tokenize(comment, '\n')) { + line = util::TrimWhitespace(line); + if (!line.empty()) { + std::string lineCopy = line.ToString(); + AppendCommentLine(lineCopy); } + } } -void AnnotationProcessor::appendNewLine() { - mComment << "\n *"; -} +void AnnotationProcessor::AppendNewLine() { comment_ << "\n *"; } -void AnnotationProcessor::writeToStream(std::ostream* out, const StringPiece& prefix) const { - if (mHasComments) { - std::string result = mComment.str(); - for (StringPiece line : util::tokenize(result, '\n')) { - *out << prefix << line << "\n"; - } - *out << prefix << " */" << "\n"; +void AnnotationProcessor::WriteToStream(std::ostream* out, + const StringPiece& prefix) const { + if (has_comments_) { + std::string result = comment_.str(); + for (StringPiece line : util::Tokenize(result, '\n')) { + *out << prefix << line << "\n"; } + *out << prefix << " */" + << "\n"; + } - if (mAnnotationBitMask & kDeprecated) { - *out << prefix << "@Deprecated\n"; - } + if (annotation_bit_mask_ & kDeprecated) { + *out << prefix << "@Deprecated\n"; + } - if (mAnnotationBitMask & kSystemApi) { - *out << prefix << "@android.annotation.SystemApi\n"; - } + if (annotation_bit_mask_ & kSystemApi) { + *out << prefix << "@android.annotation.SystemApi\n"; + } } -} // namespace aapt +} // namespace aapt |