Skip to content

Commit 94e1fe2

Browse files
committed
Improve handling of Java generics.
1 parent b803756 commit 94e1fe2

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎java2python/config/default.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
(Type('FALSE'), transform.false2False),
150150
(Type('TRUE'), transform.true2True),
151151
(Type('IDENT'), transform.keywordSafeIdent),
152+
(Type('GENERIC_TYPE_ARG_LIST'), transform.deleteGenericTypeArgList),
152153

153154
(Type('DECIMAL_LITERAL'), transform.syntaxSafeDecimalLiteral),
154155
(Type('FLOATING_POINT_LITERAL'), transform.syntaxSafeFloatLiteral),

‎java2python/mod/transform.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ def keywordSafeIdent(node, config, invalid=invalidPythonNames()):
3333
if ident in invalid:
3434
node.token.text = '%s_' % ident
3535

36+
def deleteGenericTypeArgList(node, config, invalid=invalidPythonNames()):
37+
"""Remove the parametrized types of the form T<T1, T2, ...> so they get
38+
translated only to A.
39+
"""
40+
while node.getChildCount() > 0:
41+
node.deleteChild(0)
3642

3743
def makeConst(v):
3844
""" Returns a closure that indiscriminately changes node text to a value. """

0 commit comments

Comments
 (0)