From 94d7fb5940e81d3f11d0d47bedf4780651a6b900 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Thu, 4 Oct 2018 19:50:47 +0200 Subject: Fix type as variable name --- src/Lang/Cpp/CppParser.ts | 2 +- src/test/CppTests/Parameters.test.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Lang/Cpp/CppParser.ts b/src/Lang/Cpp/CppParser.ts index 746c11c..f080483 100644 --- a/src/Lang/Cpp/CppParser.ts +++ b/src/Lang/Cpp/CppParser.ts @@ -260,7 +260,7 @@ export default class CppParser implements ICodeParser { // Special case group up the fundamental types with the modifiers. // tslint:disable-next-line:max-line-length - let reMatch: string = (x.match("^(unsigned|signed|short|long|int|char|double)(\\s+(unsigned|signed|short|long|int|char|double))+(?!a-z|A-Z|:|_|\\d)") || [])[0]; + let reMatch: string = (x.match("^(unsigned|signed|short|long|int|char|double|float)(\\s*(unsigned|signed|short|long|int|char|double|float)\\s)+(?!a-z|A-Z|:|_|\\d)") || [])[0]; if (reMatch !== undefined) { return reMatch.trim(); } diff --git a/src/test/CppTests/Parameters.test.ts b/src/test/CppTests/Parameters.test.ts index 6e7293b..9487fe9 100644 --- a/src/test/CppTests/Parameters.test.ts +++ b/src/test/CppTests/Parameters.test.ts @@ -257,4 +257,12 @@ suite("C++ - Parameters Tests", () => { const result = testSetup.SetLine("void test(int foo::* memberPointer);").GetResult(); assert.equal("/**\n * @brief \n * \n * @param memberPointer \n */", result); }); + + test("Type as variable name", () => { + let result = testSetup.SetLine("void MapPoint(double latitude, double longtitude) const;").GetResult(); + assert.equal("/**\n * @brief \n * \n * @param latitude \n * @param longtitude \n */", result); + + result = testSetup.SetLine("void MapPoint(double latitude, double long int floattitude) const;").GetResult(); + assert.equal("/**\n * @brief \n * \n * @param latitude \n * @param floattitude \n */", result); + }); }); -- cgit v1.2.3