From 23ae26f33b60244ce19e8a49d43c022bc41fd719 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Fri, 2 Mar 2018 19:31:09 +0100 Subject: Improve detection of snake and UPPER case --- src/Lang/Cpp/CppParser.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Lang/Cpp/CppParser.ts b/src/Lang/Cpp/CppParser.ts index 263f984..743b842 100644 --- a/src/Lang/Cpp/CppParser.ts +++ b/src/Lang/Cpp/CppParser.ts @@ -738,7 +738,7 @@ export default class CppParser implements ICodeParser { methodCasing = containsUnderscores ? CasingType.snake : CasingType.camel; } - if (validateFrom > 0) { + if (validateFrom > 0 && methodCasing !== CasingType.uncertain) { // validate after switch (methodCasing) { case CasingType.SCREAMING_SNAKE: { @@ -752,10 +752,13 @@ export default class CppParser implements ICodeParser { } case CasingType.snake: { // Take the leading _ after removing the characters into consideration - const testCasing = this.checkCasing(name.substr(validateFrom + 1), 0); + const textCheck = name.substr(validateFrom + 1); + const testCasing = this.checkCasing(textCheck, 0); // snake if (testCasing !== CasingType.snake) { - methodCasing = CasingType.uncertain; + if (textCheck.match("([a-z\\d]+)") === null) { + methodCasing = CasingType.uncertain; + } } break; } @@ -771,12 +774,11 @@ export default class CppParser implements ICodeParser { case CasingType.UPPER: { const testCasing = this.checkCasing(name.substr(validateFrom), 0); // upper - if (testCasing !== CasingType.UPPER) { + if (name.substr(validateFrom).match("([A-Z\\d]+)") === null) { methodCasing = CasingType.uncertain; } break; } - case CasingType.uncertain: default: { break; // No op } -- cgit v1.2.3