Commit 1fd9ebfc authored by Jarek Kobus's avatar Jarek Kobus
Browse files

Fix parsing the end of class definition. In case we look for closing '"'...

Fix parsing the end of class definition. In case we look for closing '"' character we count preceding '\\' characters to detect if we should skip the '"' or not. The bug discovered during doing the similar parser for eclipse.
parent 7ce04403
......@@ -342,6 +342,19 @@ static Document::Ptr findDefinition(const Function *functionDeclaration, int *li
}
static bool isEndingQuote(const QString &contents, int quoteIndex)
{
bool endingQuote = true;
if (quoteIndex > 0) {
int previous = 1;
while (contents.at(quoteIndex - previous) == QLatin1Char('\\')) {
previous++;
endingQuote = !endingQuote;
}
}
return endingQuote;
}
// TODO: Wait for robust Roberto's code using AST or whatever for that. Current implementation is hackish.
static int findClassEndPosition(const QString &headerContents, int classStartPosition)
{
......@@ -361,7 +374,7 @@ static int findClassEndPosition(const QString &headerContents, int classStartPos
} else if (contents.at(idx) == QLatin1Char('\"')) {
do {
idx = contents.indexOf(QLatin1Char('\"'), idx + 1); // drop everything up to the nearest "
} while (idx > 0 && contents.at(idx - 1) == QLatin1Char('\\')); // if the nearest " is preceeded by \ we find next one
} while (idx > 0 && !isEndingQuote(contents, idx)); // if the nearest " is preceeded by \ (or by \\\ or by \\\\\, but not by \\ nor \\\\) we find next one
if (idx < 0)
break;
idx++;
......
Supports Markdown
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