hidl2aidl: avoid reprocessing comments
The constructor of DocComment assumes that the comments come from the
lexer and parses them in a specific way. However, this operation's lack
of idempotence means that comments sometimes lose leading spaces in
hidl2aidl.
Bug: N/A
Test: still having leading spaces in hidl2aidl output
Change-Id: Ifaf6fcb5c7b85ccf6011eafe442737cee81d46a5
diff --git a/DocComment.cpp b/DocComment.cpp
index daa16ea..b84ff3d 100644
--- a/DocComment.cpp
+++ b/DocComment.cpp
@@ -28,7 +28,7 @@
namespace android {
DocComment::DocComment(const std::string& comment, const Location& location, CommentType type)
- : mType(type), mLocation(location) {
+ : DocComment(std::vector<std::string>(), location, type) {
std::vector<std::string> lines = base::Split(base::Trim(comment), "\n");
bool foundFirstLine = false;
@@ -59,6 +59,10 @@
}
}
+DocComment::DocComment(const std::vector<std::string>& lines, const Location& location,
+ CommentType type)
+ : mLines(lines), mType(type), mLocation(location) {}
+
void DocComment::merge(const DocComment* comment) {
mLines.insert(mLines.end(), 2, "");
mLines.insert(mLines.end(), comment->mLines.begin(), comment->mLines.end());