C# simplification: remove 'using var;' code from the tokenizer.

This commit is contained in:
Edoardo Prezioso 2012-01-02 00:45:32 +01:00
parent eb657034ba
commit b24e6e659e
1 changed files with 8 additions and 1 deletions

View File

@ -2626,7 +2626,7 @@ void Tokenizer::simplifyDoublePlusAndDoubleMinus()
void Tokenizer::simplifyJavaAndCSharp() void Tokenizer::simplifyJavaAndCSharp()
{ {
// better don't call isJava in the loop // better don't call isJava in the loop
bool isJava_ = isJava(); const bool isJava_ = isJava();
for (Token *tok = _tokens; tok; tok = tok->next()) { for (Token *tok = _tokens; tok; tok = tok->next()) {
if (tok->str() == "private") if (tok->str() == "private")
tok->str("private:"); tok->str("private:");
@ -2639,6 +2639,13 @@ void Tokenizer::simplifyJavaAndCSharp()
if (Token::Match(tok, ") throws %var% {")) if (Token::Match(tok, ") throws %var% {"))
tok->deleteNext(2); tok->deleteNext(2);
} else { } 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 //simplify C# arrays of arrays and multidimension arrays
while (Token::Match(tok, "%type% [ ,|]") && while (Token::Match(tok, "%type% [ ,|]") &&
(!tok->previous() || Token::Match(tok->previous(), "[,;{}]"))) { (!tok->previous() || Token::Match(tok->previous(), "[,;{}]"))) {