By pressing request, extract method: simplifyJavaAndCSharp.

This commit is contained in:
Edoardo Prezioso 2011-12-28 22:44:53 +01:00
parent f9dd927ff4
commit ec0badb651
2 changed files with 7 additions and 28 deletions

View File

@ -1988,6 +1988,10 @@ bool Tokenizer::tokenize(std::istream &code,
}
}
// Simplify JAVA/C# code
if (isJavaOrCSharp())
simplifyJavaAndCSharp();
if (!createLinks()) {
// Source has syntax errors, can't proceed
return false;
@ -2033,34 +2037,6 @@ bool Tokenizer::tokenize(std::istream &code,
}
}
// Simplify JAVA/C# code
if (isJavaOrCSharp()) {
// better don't call isJava in the loop
bool isJava_ = isJava();
for (Token *tok = _tokens; tok; tok = tok->next()) {
if (tok->str() == "private")
tok->str("private:");
else if (tok->str() == "protected")
tok->str("protected:");
else if (tok->str() == "public")
tok->str("public:");
else if (isJava_) {
if (Token::Match(tok, ") throws %var% {"))
tok->deleteNext(2);
} else {
if (Token::Match(tok, "%type% [ ] %var% [=;]") &&
(!tok->previous() || Token::Match(tok->previous(), "[;{}]"))) {
tok->deleteNext(2);
tok->insertToken("*");
tok = tok->tokAt(2);
if (tok->next()->str() == "=")
tok = tok->next();
}
}
}
}
// Convert K&R function declarations to modern C
simplifyVarDecl(true);

View File

@ -233,6 +233,9 @@ public:
*/
bool simplifyCalculations();
/** Simplify Java and C# syntax */
void simplifyJavaAndCSharp();
/** Insert array size where it isn't given */
void arraySize();