summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-05-20 07:42:26 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-05-20 07:45:38 (GMT)
commit23a0475c4676797de987c7a1e11e9593f57631a8 (patch)
tree53813203be1b7187a690e01a401aa656a1ff5f5c /tools
parent6526b67bb64cc9d4db081101a5eb4a5c6f7c2456 (diff)
downloadQt-23a0475c4676797de987c7a1e11e9593f57631a8.zip
Qt-23a0475c4676797de987c7a1e11e9593f57631a8.tar.gz
Qt-23a0475c4676797de987c7a1e11e9593f57631a8.tar.bz2
Fix parsing method calls with null arguments in Java code
In Java, "null" is represented as a keyword, not as the integer 0. The old code assumed the latter. Code such as translate("fooBar", "fooBar", null); would thus not be detected by lupdate when parsing Java files. Reviewed-by: ossi
Diffstat (limited to 'tools')
-rw-r--r--tools/linguist/shared/java.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/linguist/shared/java.cpp b/tools/linguist/shared/java.cpp
index 912a8d7..4c244d2 100644
--- a/tools/linguist/shared/java.cpp
+++ b/tools/linguist/shared/java.cpp
@@ -58,7 +58,7 @@ enum { Tok_Eof, Tok_class, Tok_return, Tok_tr,
Tok_Comment, Tok_String, Tok_Colon, Tok_Dot,
Tok_LeftBrace, Tok_RightBrace, Tok_LeftParen,
Tok_RightParen, Tok_Comma, Tok_Semicolon,
- Tok_Integer, Tok_Plus, Tok_PlusPlus, Tok_PlusEq };
+ Tok_Integer, Tok_Plus, Tok_PlusPlus, Tok_PlusEq, Tok_null };
class Scope
{
@@ -142,7 +142,11 @@ static int getToken()
case 'c':
if ( yyIdent == QLatin1String("class") )
return Tok_class;
- break;
+ break;
+ case 'n':
+ if ( yyIdent == QLatin1String("null") )
+ return Tok_null;
+ break;
}
}
switch ( yyIdent.at(0).toLatin1() ) {
@@ -382,9 +386,11 @@ static bool matchInteger( qlonglong *number)
static bool matchStringOrNull(QString &s)
{
bool matches = matchString(s);
- qlonglong num = 0;
- if (!matches) matches = matchInteger(&num);
- return matches && num == 0;
+ if (!matches) {
+ matches = (yyTok == Tok_null);
+ if (matches) yyTok = getToken();
+ }
+ return matches;
}
/*