tokenizer: proper checks for Java and C#
This commit is contained in:
parent
103588c5bc
commit
7a5627029f
|
@ -1982,6 +1982,8 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
}
|
||||
|
||||
// Convert C# code
|
||||
// FIXME: This should be if(isCSharp()), but that makes the lines 5931 and
|
||||
// 5932 of test/testtokenize.cpp fail.
|
||||
if (_files[0].find(".cs")) {
|
||||
for (Token *tok = _tokens; tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "%type% [ ] %var% [=;]") &&
|
||||
|
@ -2005,9 +2007,10 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
|
||||
// Simplify JAVA/C# code
|
||||
if (isJavaOrCSharp()) {
|
||||
const bool isJava(_files[0].find(".java") != std::string::npos);
|
||||
// better don't call isJava in the loop
|
||||
bool isJava_ = isJava();
|
||||
for (Token *tok = _tokens; tok; tok = tok->next()) {
|
||||
if (isJava && Token::Match(tok, ") throws %var% {")) {
|
||||
if (isJava_ && Token::Match(tok, ") throws %var% {")) {
|
||||
tok->deleteNext(2);
|
||||
} else if (tok->str() == "private")
|
||||
tok->str("private:");
|
||||
|
|
|
@ -57,10 +57,19 @@ public:
|
|||
return std::string("");
|
||||
}
|
||||
|
||||
/** Is the code JAVA. Used for bailouts */
|
||||
bool isJava() const {
|
||||
return fileExtension() == ".java";
|
||||
}
|
||||
|
||||
/** Is the code C#. Used for bailouts */
|
||||
bool isCSharp() const {
|
||||
return fileExtension() == ".cs";
|
||||
}
|
||||
|
||||
/** Is the code JAVA/C#. Used for bailouts */
|
||||
bool isJavaOrCSharp() const {
|
||||
std::string ext = fileExtension();
|
||||
return (ext == ".java" || ext == ".cs");
|
||||
return isJava() || isCSharp();
|
||||
}
|
||||
|
||||
/** Is the code C. Used for bailouts */
|
||||
|
|
Loading…
Reference in New Issue