Move non-C++ simplification outside big loop.
Related to commit b2f8161862
.
This commit is contained in:
parent
0a588496a0
commit
f9dd927ff4
|
@ -2025,23 +2025,6 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
tok->next()->str("-" + tok->next()->str());
|
||||
}
|
||||
|
||||
// Simplify JAVA/C# code
|
||||
if (isJava() && Token::Match(tok, ") throws %var% {"))
|
||||
tok->deleteNext(2);
|
||||
else if (isJavaOrCSharp() && tok->str() == "private")
|
||||
tok->str("private:");
|
||||
else if (isJavaOrCSharp() && tok->str() == "protected")
|
||||
tok->str("protected:");
|
||||
else if (isJavaOrCSharp() && tok->str() == "public")
|
||||
tok->str("public:");
|
||||
|
||||
// Convert exclusive C# code
|
||||
if (isCSharp() && Token::Match(tok, "%type% [ ] %var% [=;]") &&
|
||||
(!tok->previous() || Token::Match(tok->previous(), "[;{}]"))) {
|
||||
tok->deleteNext(2);
|
||||
tok->insertToken("*");
|
||||
}
|
||||
|
||||
// simplify round "(" parenthesis between "[;{}] and "{"
|
||||
if (Token::Match(tok, "[;{}] ( {") &&
|
||||
Token::simpleMatch(tok->linkAt(2), "} ) ;")) {
|
||||
|
@ -2050,6 +2033,35 @@ 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);
|
||||
simplifyFunctionParameters();
|
||||
|
|
Loading…
Reference in New Issue