By pressing request, extract method: simplifyJavaAndCSharp.
This commit is contained in:
parent
f9dd927ff4
commit
ec0badb651
|
@ -1988,6 +1988,10 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Simplify JAVA/C# code
|
||||||
|
if (isJavaOrCSharp())
|
||||||
|
simplifyJavaAndCSharp();
|
||||||
|
|
||||||
if (!createLinks()) {
|
if (!createLinks()) {
|
||||||
// Source has syntax errors, can't proceed
|
// Source has syntax errors, can't proceed
|
||||||
return false;
|
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
|
// Convert K&R function declarations to modern C
|
||||||
simplifyVarDecl(true);
|
simplifyVarDecl(true);
|
||||||
|
|
|
@ -233,6 +233,9 @@ public:
|
||||||
*/
|
*/
|
||||||
bool simplifyCalculations();
|
bool simplifyCalculations();
|
||||||
|
|
||||||
|
/** Simplify Java and C# syntax */
|
||||||
|
void simplifyJavaAndCSharp();
|
||||||
|
|
||||||
/** Insert array size where it isn't given */
|
/** Insert array size where it isn't given */
|
||||||
void arraySize();
|
void arraySize();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue