From b24e6e659ee7d076affe8794149a4e7e1c932719 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Mon, 2 Jan 2012 00:45:32 +0100 Subject: [PATCH] C# simplification: remove 'using var;' code from the tokenizer. --- lib/tokenize.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index a2ea8433b..ae482b814 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2626,7 +2626,7 @@ void Tokenizer::simplifyDoublePlusAndDoubleMinus() void Tokenizer::simplifyJavaAndCSharp() { // better don't call isJava in the loop - bool isJava_ = isJava(); + const bool isJava_ = isJava(); for (Token *tok = _tokens; tok; tok = tok->next()) { if (tok->str() == "private") tok->str("private:"); @@ -2639,6 +2639,13 @@ void Tokenizer::simplifyJavaAndCSharp() if (Token::Match(tok, ") throws %var% {")) tok->deleteNext(2); } else { + //remove 'using var;' from code + if (Token::Match(tok, "using %var% ;") && + (!tok->previous() || Token::Match(tok->previous(), "[,;{}]"))) { + tok->deleteNext(2); + tok->deleteThis(); + } + //simplify C# arrays of arrays and multidimension arrays while (Token::Match(tok, "%type% [ ,|]") && (!tok->previous() || Token::Match(tok->previous(), "[,;{}]"))) {