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
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user