summaryrefslogtreecommitdiff
path: root/tools/aapt2/java/AnnotationProcessor.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-07-24 18:19:36 -0700
committerAdam Lesinski <adamlesinski@google.com>2017-07-25 15:53:15 -0700
commite967d3f6ac2e1e1f612f99b9c76abcb9e13bb7a2 (patch)
tree57a3a90478daeaf536af29463e3ac3866777511c /tools/aapt2/java/AnnotationProcessor.cpp
parent3370d3230d4e3084ca95eb6d6bb63f27c3cb6f63 (diff)
AAPT2: Fix JavaDoc first sentence extraction.
The old algorithm for detecting the first sentence of a JavaDoc comment looked for the first occurence of '.'. This does not work when code or a {@link android.R.styleable} link is encountered in the first sentence. Switch to checking for whitespace characters after the '.' character. Bug: 62900335 Test: make aapt2_tests Change-Id: I8238f6a6304c9c2f92e2e576ca8962a59c2b20ea
Diffstat (limited to 'tools/aapt2/java/AnnotationProcessor.cpp')
-rw-r--r--tools/aapt2/java/AnnotationProcessor.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/aapt2/java/AnnotationProcessor.cpp b/tools/aapt2/java/AnnotationProcessor.cpp
index a0ef00b1ea1f..1f83fa098d74 100644
--- a/tools/aapt2/java/AnnotationProcessor.cpp
+++ b/tools/aapt2/java/AnnotationProcessor.cpp
@@ -18,12 +18,29 @@
#include <algorithm>
+#include "text/Unicode.h"
+#include "text/Utf8Iterator.h"
#include "util/Util.h"
-using android::StringPiece;
+using ::aapt::text::Utf8Iterator;
+using ::android::StringPiece;
namespace aapt {
+StringPiece AnnotationProcessor::ExtractFirstSentence(const StringPiece& comment) {
+ Utf8Iterator iter(comment);
+ while (iter.HasNext()) {
+ const char32_t codepoint = iter.Next();
+ if (codepoint == U'.') {
+ const size_t current_position = iter.Position();
+ if (!iter.HasNext() || text::IsWhitespace(iter.Next())) {
+ return comment.substr(0, current_position);
+ }
+ }
+ }
+ return comment;
+}
+
void AnnotationProcessor::AppendCommentLine(std::string& comment) {
static const std::string sDeprecated = "@deprecated";
static const std::string sSystemApi = "@SystemApi";