summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2019-10-08 19:13:55 +0200
committerChristoph Schlosser <christophschlosser@users.noreply.github.com>2019-10-08 22:04:49 +0200
commit3c16da1b09b4a7490e2139d1ee3b96e4ed096806 (patch)
tree2f50f52c12628a6c6278c58eaa7b5635d79922cf /src
parentd009b9190ed48e3a3787b58e02915f5ec195c84b (diff)
downloaddoxdocgen-3c16da1b09b4a7490e2139d1ee3b96e4ed096806.tar.gz
End of declaration problem fixed
If the terminating character is the first one on the next line it can cause the buffer to fill and thus produce malformed text to parse.
Diffstat (limited to 'src')
-rw-r--r--src/Lang/Cpp/CppParser.ts7
-rw-r--r--src/test/CppTests/Attributes.test.ts5
2 files changed, 10 insertions, 2 deletions
diff --git a/src/Lang/Cpp/CppParser.ts b/src/Lang/Cpp/CppParser.ts
index 2ea3c3f..3b13721 100644
--- a/src/Lang/Cpp/CppParser.ts
+++ b/src/Lang/Cpp/CppParser.ts
@@ -401,6 +401,7 @@ export default class CppParser implements ICodeParser {
nextLine = new Position(nextLine.line + 1, nextLine.character);
nextLineTxt = this.activeEditor.document.lineAt(nextLine.line).text.trim();
let finalSlice = 0;
+ let endOfDeclaration = false;
// Check if method has finished if curly brace is opened while
// nesting is occuring.
@@ -411,11 +412,13 @@ export default class CppParser implements ICodeParser {
currentNest--;
} else if (nextLineTxt[i] === "{" && currentNest === 0) {
finalSlice = i;
+ endOfDeclaration = true;
break;
} else if ((nextLineTxt[i] === ";"
|| (nextLineTxt[i] === ":" && nextLineTxt[i - 1] !== ":" && nextLineTxt[i + 1] !== ":"))
&& currentNest === 0) {
finalSlice = i;
+ endOfDeclaration = true;
break;
}
}
@@ -428,7 +431,7 @@ export default class CppParser implements ICodeParser {
if (!this.isVsCodeAutoComplete(nextLineTxt)) {
logicalLine += "\n";
- if (finalSlice > 0) {
+ if (endOfDeclaration === true) {
logicalLine += nextLineTxt.slice(0, finalSlice);
} else {
logicalLine += nextLineTxt;
@@ -436,7 +439,7 @@ export default class CppParser implements ICodeParser {
logicalLine.replace(/\*\//g, "");
}
- if (finalSlice > 0) {
+ if (endOfDeclaration) {
return logicalLine.replace(/^\s+|\s+$/g, "");
}
}
diff --git a/src/test/CppTests/Attributes.test.ts b/src/test/CppTests/Attributes.test.ts
index bfeaef1..a6641e1 100644
--- a/src/test/CppTests/Attributes.test.ts
+++ b/src/test/CppTests/Attributes.test.ts
@@ -59,4 +59,9 @@ suite("C++ - Attributes Tests", () => {
const result = testSetup.SetLine("constexpr int foo(int a, double& b) throw(std::except);").GetResult();
assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return constexpr int \n */", result);
});
+
+ test("Newline in function", () => {
+ const result = testSetup.SetLines(["static void ResetActionState( BOOL sendNAK )", "{"]).GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param sendNAK \n */", result);
+ });
});