Commit e154151c authored by Ralf Habacker's avatar Ralf Habacker

Initial work for combining multi line c++ comments

parent 3f2d6e6b
......@@ -1851,11 +1851,12 @@ void Parser::eventuallyTakeComment(int startLn, int endLn, Type& ast)
template<class Type>
void Parser::eventuallyTakeComment(Type& ast)
{
if (&(*ast) && comment()) {
ast->setComment(comment());
}
int line = currentLine();
Comment c = m_commentStore.getCommentsInRange(line);
clearComment();
if (&(*ast) && c) {
ast->setComment(c);
}
}
void Parser::clearComment()
......
......@@ -168,7 +168,7 @@ public:
{
format();
rhs.format();
m_text += QLatin1String(" ") + rhs.m_text;
m_text += QLatin1String("\n") + rhs.m_text;
}
operator bool() const
......@@ -234,6 +234,28 @@ public:
}
}
/**
* Returns the comments between "end" (inclusive) and "start" and removes it
* @param end last line to return
* @param start start line to return
* @return instance of class Comment with combined comment
*/
Comment getCommentsInRange(int end, int start = 0)
{
CommentSet::iterator it = m_comments.begin();
Comment ret;
while (it != m_comments.end() && (*it).line() >= start && (*it).line() <= end) {
if (ret)
ret += *it;
else
ret = *it;
m_comments.erase(it);
++it;
}
return ret;
}
///Returns and removes the comment in the line
Comment getComment(int line)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment